472,791 Members | 1,049 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 5476
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.