link to iframe page (load specific content)

S

SigRob

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
 
V

VK

PAGE1:
<a href="foo.html?bar.html" target="PAGE1">link</a>

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

(iframeName loads bar.html)
 
S

SigRob

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
 
V

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.
 
S

SigRob

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
 
S

SigRob

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top