473,320 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Change target of links in page

Hi,

I have a webpage with two Iframe's. I want to be able to change the
target of all links in one frame so it will point to the other frame and
all this from the main page. Is this possible and if so how?

Thanks in advance, Maarten

Jul 23 '05 #1
9 5496
Muffinman wrote:
Hi,

I have a webpage with two Iframe's. I want to be able to change the
target of all links in one frame so it will point to the other frame and
all this from the main page. Is this possible and if so how?


Yes its possible.

Open all your pages in a text editor.
Search and replace the target="" attributes to what you want them to be.
Save all your pages.
Reupload all your pages.

Now, they are targeted properly.

Look Ma, no Javascript!!!!

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2
Ivo
"Muffinman" wrote

I have a webpage with two Iframe's. I want to be able to change the
target of all links in one frame so it will point to the other frame and
all this from the main page. Is this possible and if so how?


Make sure your iframes are properly named. Then loop through all links in
them and adjust each link's target property accordingly:

var f=window.frames['MyFirstFrame'].document.links;
var i=f.length;
while(i--){
f[i].target='MyOtherFrame';
}
var f=window.frames['MyOtherFrame'].document.links;
var i=f.length;
while(i--){
f[i].target='MyFirstFrame';
}

This looks repetetive already... I 'm sure it can be improved.
--
Ivo
http://www.vansandick.com/

Jul 23 '05 #3
First place: I'm lazy. Secondly with about a thousand pages and no
target to replace.. this can be rather difficult.

Maarten

Randy Webb wrote:
Muffinman wrote:
Hi,

I have a webpage with two Iframe's. I want to be able to change the
target of all links in one frame so it will point to the other frame
and all this from the main page. Is this possible and if so how?

Yes its possible.

Open all your pages in a text editor.
Search and replace the target="" attributes to what you want them to be.
Save all your pages.
Reupload all your pages.

Now, they are targeted properly.

Look Ma, no Javascript!!!!


Jul 23 '05 #4
First off all: I'm lazy and what I want is usually possible... Secondly:
with over a thousand pages and no target pressent to change, this can be
rather difficult.

MI

Randy Webb wrote:
Muffinman wrote:
Hi,

I have a webpage with two Iframe's. I want to be able to change the
target of all links in one frame so it will point to the other frame
and all this from the main page. Is this possible and if so how?

Yes its possible.

Open all your pages in a text editor.
Search and replace the target="" attributes to what you want them to be.
Save all your pages.
Reupload all your pages.

Now, they are targeted properly.

Look Ma, no Javascript!!!!


Jul 23 '05 #5
Excellent, works perfect.. thanks.

Maarten

Ivo wrote:
"Muffinman" wrote
I have a webpage with two Iframe's. I want to be able to change the
target of all links in one frame so it will point to the other frame and
all this from the main page. Is this possible and if so how?

Make sure your iframes are properly named. Then loop through all links in
them and adjust each link's target property accordingly:

var f=window.frames['MyFirstFrame'].document.links;
var i=f.length;
while(i--){
f[i].target='MyOtherFrame';
}
var f=window.frames['MyOtherFrame'].document.links;
var i=f.length;
while(i--){
f[i].target='MyFirstFrame';
}

This looks repetetive already... I 'm sure it can be improved.
--
Ivo
http://www.vansandick.com/


Jul 23 '05 #6
Muffinman wrote:
First off all: I'm lazy and what I want is usually possible... Secondly:
with over a thousand pages and no target pressent to change, this can be
rather difficult.


Your laziness is obvious by your lack of ability to scroll down, snip,
and reply in order. But I wouldn't expect you to understand that.

As for cycling through all your links, what target attribute will they
have if the user has JS disabled?

Furthermore, it is trivial to install Apache and PHP on a PC and then
write a PHP script that will search all pages, remove all target
attributes (if present) and then search them all again and add the
target attribute. But of course, you are too lazy for that, right?

If you are that lazy, then why should we waste our time to answer you?

P.S. Read the FAQ via the signature. That is, if you are not too lazy to
scroll down that far.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #7

Your laziness is obvious by your lack of ability to scroll down, snip,
and reply in order. But I wouldn't expect you to understand that.
That's more on how I prefer to answer messages.

As for cycling through all your links, what target attribute will they
have if the user has JS disabled?
Than that user has to enable that. The site won't work anyway without JS
and it can't be done without JS or at least it will make it a lot harder
for the user. I'm not writing a conventional web site but more a sort
of/part of, program..

Furthermore, it is trivial to install Apache and PHP on a PC and then
write a PHP script that will search all pages, remove all target
attributes (if present) and then search them all again and add the
target attribute. But of course, you are too lazy for that, right?
I considered that but since I can not know which pages exactly have to
be changed this is not an option. BTW. all these pages have been created
with php.

If you are that lazy, then why should we waste our time to answer you?
That's up to you. Laziness knows a few forms. For me it meant learning a
whole lot more than I initially intended to do. Unfortunately it is a
lot harder to do without the help of others.

P.S. Read the FAQ via the signature. That is, if you are not too lazy to
scroll down that far.


You make it sound as if laziness is a negative thing, do some more
thinking on that. Most of what we have is build on laziness...
Why does your kind always answer questions so aggressively? (<- These
are usually not my experiences but more on what I read on answers in
various groups )

Well, I am not gonna spend more time on you..

Maarten


Jul 23 '05 #8
Muffinman wrote:

<--snip-->

As for cycling through all your links, what target attribute will they
have if the user has JS disabled?

Than that user has to enable that. The site won't work anyway without JS
and it can't be done without JS or at least it will make it a lot harder
for the user. I'm not writing a conventional web site but more a sort
of/part of, program..


I am not sure I agree with the "lot harder for the user". User clicks a
button/link, something happens. Its no harder on the user whether the
action comes from a script or a server. The difference a JS dependency
makes is on the load on the server versus the client. But its moot. The
fact that you are creating an intra-net type application makes a huge
difference in the responses you get in this group.

Furthermore, it is trivial to install Apache and PHP on a PC and then
write a PHP script that will search all pages, remove all target
attributes (if present) and then search them all again and add the
target attribute. But of course, you are too lazy for that, right?

I considered that but since I can not know which pages exactly have to
be changed this is not an option. BTW. all these pages have been created
with php.


Its a lot simpler to let PHP handle it before the page is sent to the
browser than it is for JS to handle it. It would only take one pass of
PHP through every file, replace the target's and save the files. Then it
never has to be done again. But when its served with one target and JS
has to change it, it has to do it every single time the page is loaded.

<--snip-->

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #9


Randy Webb wrote:
Muffinman wrote:

<--snip-->

As for cycling through all your links, what target attribute will
they have if the user has JS disabled?
Than that user has to enable that. The site won't work anyway without
JS and it can't be done without JS or at least it will make it a lot
harder for the user. I'm not writing a conventional web site but more
a sort of/part of, program..

I am not sure I agree with the "lot harder for the user". User clicks a
button/link, something happens. Its no harder on the user whether the
action comes from a script or a server. The difference a JS dependency
makes is on the load on the server versus the client. But its moot. The


This is what I meant with that you do not know what I am trying to do.
The whole point is to make it an offline application. As I do not have a
internet connection at home and I have access to an online library I
wrote this PHP script to download several books. With javascript I want
to create a menu for easier navigation through the book. Main functions
are working now.. but it still needs some improvement.

fact that you are creating an intra-net type application makes a huge
difference in the responses you get in this group.
I'm not sure what you mean with this. The part of the app. we are
discussing now is completely offline... local..

Furthermore, it is trivial to install Apache and PHP on a PC and then
write a PHP script that will search all pages, remove all target
attributes (if present) and then search them all again and add the
target attribute. But of course, you are too lazy for that, right?


I considered that but since I can not know which pages exactly have to
be changed this is not an option. BTW. all these pages have been created
with php.

Its a lot simpler to let PHP handle it before the page is sent to the
browser than it is for JS to handle it. It would only take one pass of
PHP through every file, replace the target's and save the files. Then it
never has to be done again. But when its served with one target and JS
has to change it, it has to do it every single time the page is loaded.

As I stated before: I can not exactly know which pages have to be edited
exept for that they are somewhere among the first twenty pages.

Maarten

Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lars Schlanbusch | last post by:
Hi! Is there any way to set <base target="_blank"> for links which link to a page outside the domain, and <base target="_self"> for links which link to a page inside the domain? Can i do such...
3
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited...
4
by: Andrea | last post by:
Hi everyone. I'm working on a navigation menu (in a frameset) that I want to set the "active" link to black (the link that corresponds to the page displayed in the right side of the frame) to...
16
by: Mark van Ballegooijen | last post by:
When using the XHTML 1.0 validator at http://validator.w3.org/check, an error will be raised for every instance of a "target" attribute in "A" elements. Is it truely because it is not part of this...
4
by: Matt | last post by:
When the user resize the browser, the "Frequently Used Link" and "Table 1" and "Table 2" will shift to the left hand side, but table position is unchanged. I really have no idea how to fix that. I...
10
by: Richard | last post by:
The style sheet shown below is from the suckerfish vertical menu. http://www.htmldog.com/articles/suckerfish/dropdowns/example/vertical.html I've added in a few minor changes to color code the...
4
by: Richard Cornford | last post by:
For the last couple of months I have been trying to get the next round of updates to the FAQ underway and been being thwarted by a heavy workload (the project I am working on has to be finished an...
8
by: Mateusz Viste | last post by:
Hi, I'm not sure if my question is really related to JavaScript, so please excuse me if that's not the case (and maybe you guys would have an idea what's the cause is and where could I ask)... ...
4
Dököll
by: Dököll | last post by:
Hey Gang! I thought I had a good idea but then I realized JSF doesn't play that... I am trying to mimick what HTML can do in JSF when using target tags to related to inner HTML pages. In...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.