469,572 Members | 1,306 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

link to iframe page (load specific content)

I have PAGE1 with the link to PAGE2 with iframe. (iframe load several
naked html). I want to add directive to the link to point sprcific
content of iframe.

to make it clear

link on PAGE1 -> load PAGE2 with iframe -> iframe content is specified
on link = whole PAGE2 with iframe with desired content...

Please help...

solving problem with creating several different PAGEs2 poining wanted
iframe src is not the case

SigRob

Oct 22 '05 #1
5 4318
VK
PAGE1:
<a href="foo.html?bar.html" target="PAGE1">link</a>

PAGE2:
<body onload="iframeName.src=self.location.search">

(iframeName loads bar.html)

Oct 22 '05 #2
I know we are close, but is not working yet...

---start.html---
<html>
<head><title>start.html</title></head>
<body>
<a href="foo.html?bar.html" target="_self">link</a>
</body></html>

----foo.html---
<html>
<head><title>foo.html</title></head>
<body onload="frame.src=self.location.search">
test frame to load specific content<br>
<iframe name="frame" height="300" width="300" align="middle" border="1"
frameborder="yes" </iframe>
</body></html>

---bar.html---
<html><body>
if you see this inside frame it means script is working
</body></html>
state is: if you click on link foo.html is loaded with ?bar.html added
to address line - so far so good but somehow bar.html is not loading
into frame - frame stays empty.

One more issue - what will happen if frame has defined start page ie.
src=bar_start.html

thanx

Oct 23 '05 #3
VK
1) do not use "frame" as the name. "myFrame", "frame01" etc. are much
safer.

2) JavaScript specs state that location.search must contain characters
*following* the question mark (thus not *containing* it). Despite that
there is currently an implementation negligeance in some browsers when
the location.search is extracted together with "?" at the beginning.
Surprisingly enough FF is one of these browsers, at least it was.
Try alert(location.search) to see if your browser follows the specs. If
not, left-trim the string.
One more issue - what will happen if frame has defined start page ie.
src=bar_start.html

If you're expecting non-CGI chars in the file name, use
myFrame.src=unescape(location.search). You don't need to escape them in
the link: browser will do it for you.

Oct 23 '05 #4
What I wanted to say mentioning the question mark is your script is
working in halve way. In my opinion is giving direction to foo.html to
load bar.html but it is not happening. You can see this in the address
bar.
it looks like this --address/foo.html?bar.html for me OK

I am not adding ? manually!!! Come on....

I have checked this on IE and FF with the same result bar.html is not
loading into frame.

Question about frame src arise in my mind because if you access
foo.html directly you might want to have a bar_start page loaded into
frame. I want! But from any other page I want to load specific content
to this frame. As soon as this script works I can cover loading
directly foo.html in the same way like others, because in this case
specified content of the frame will be bar_start page.

...just have to make this working

Oct 23 '05 #5
This is what the I like moust - it working...look on <body onload=
string

<html><head>
<title>foo.html</title>
</head>

<body onload="frame1.location.href = self.location.search.substr(1)">

test frame to load specific content<br>
<iframe name="frame1" height="300" width="300" align="middle"
border="1"
frameborder="yes"> </iframe>
</body></html>

let's spread it... thanks for your help VK! alert made the progress

Oct 24 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Paul Brant | last post: by
2 posts views Thread by Jeronimo Bertran | last post: by
3 posts views Thread by PCgeek | last post: by
7 posts views Thread by Tom Cole | last post: by
11 posts views Thread by nma | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.