IFrame Question
missylm999
Status: New User - Welcome
Joined: 01 Mar 2005
Posts: 2
Reply Quote
I am trying to use an iframe on my page. I have it in the middle of my page. When I click on a link to this page from another page or from my table of contents the page opens up right at the iframe and not at the top of the page like it should. Is there a way to work aroudn this? Should I use an onLoad event or something to tell the page to open up at the top and not at the iframe?
Back to top
erikZ
Status: Contributor
Joined: 30 May 2004
Posts: 148
Reply Quote
Hi missylm999, welcome to the forums.

I'm not exactly clear on what you are asking, so I'll take a guess:

Is what you want to happen that when you click a link in your navigation, which is on the page containing the iframe that the page loads in the iframe? And what is currently happening is that the page in the iframe is instead loading, replacing the page containing the iframe?

If this is the question, the solution is very simple:

:: Code ::
<a href="iframe-content-page1.html" target="main1">Navigation link to iframe</a>

<iframe src="default-page-iframe-opens-on.html" id="main1" name="name1"></iframe>


The key here is to use the name/id combination on the iframe to tell the links on the page where it is, and to use that same name / id in the <a href.... target="main1"> tag to tell the link to go to the target of the name / id of the iframe.

Name and id are used to maintain backward compatibility for older browsers, otherwise you'd just use 'id'.

If you are trying to do something more complex, please describe exactly what you are trying to make happen, if necessary include snippets of the relevant code, but please don't put in the entire page HTML.
Back to top
iframes
missylm999
Status: New User - Welcome
Joined: 01 Mar 2005
Posts: 2
Reply Quote
No, I might not have explained it correctly. Basically what is happening is I have a table of contents that links to a number of pages with information on them. On one of those pages I have put an iframe to pull in some information from another page.

When I click to go to that page from the table of contents instead of opening up the page at the top where I want it to, the page opens and goes straight to the iframe. But, the iframe is at the end of the page. There is a lot of information above this iframe I want the user to be able to see. It is almost like the iframe is working as an a tag, which I do not want it to do.

How do I avoid this from happening?
Back to top
erikZ
Status: Contributor
Joined: 30 May 2004
Posts: 148
Reply Quote
:: Quote ::
It is almost like the iframe is working as an a tag, which I do not want it to do.

I can't really follow what you're asking at all. The iframe is a tag, like <img...> or whatever else.

The iframe will be wherever you put it on the page, like any other tag, and its content will be inside of it.

Why don't you post your iframe html, it sounds like you've made some coding error as far as I can tell, but I can't really understand what the problem is.

:: Quote ::
the page opens and goes straight to the iframe. But, the iframe is at the end of the page. There is a lot of information above this iframe I want the user to be able to see

You must be using the #main1 on the navigation links, that's the only way you can be getting the page to do that behavior.

So your navigation is this:
:: Code ::
<a href="link.html#main1">Iframe page</a>

I'd guess, which of course sends the page to the name 'main1' like it's supposed to.

Post some of your navigation link code and the iframe code and it should be clear right away what the problem is.
Back to top
Jumping to iFrame
Mark Smit
Status: Curious
Joined: 25 May 2005
Posts: 6
Location: Netherlands
Reply Quote
Hi missylm999

I came across this old post and recognized your problem immediately: Whenever the user clicks on a link to the nested iFrame from within the enclosing page, the browser immediately scrolls down to the iFrame. I have an internal page on our intranet that suffers from the same problem.

In my case, the iFrame is 100 pixels from the top, and the browser consistently jumps down to show as much of the iFrame as it can whenever the user clicks on a link that points the iFrame to a new page or to an anchor or id inside the iFrame.

Did you find a solution yet? Otherwise, perhaps my explanation will trigger someone else...
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
if the page is on your server, may i ask, why use an iframe?
Back to top
Mark Smit
Status: Curious
Joined: 25 May 2005
Posts: 6
Location: Netherlands
Reply Quote
Hi Mike, good question. We use an iframe here because the outer page allows our testers to load different pages containing regression tests, and a bottom scrollarea iframe showns the correponding test script. Are you suggesting that this can also be achieve using document rewriting into a div?
Back to top
mike
Status: Contributor
Joined: 08 Oct 2004
Posts: 71
Reply Quote
it seems feasible to me. I really would need to know more about how compicated the whole thing is.
what doctype are you using? one option would to be to use layers. you could also maybe use javscripts, css and includes to do it. i wouldn't really be able to know until i tried. perhaps a div and the object tag mixed with some js. the more i read on the subject i think the object tag may be the way to go mixed with js and css
Back to top
Mark Smit
Status: Curious
Joined: 25 May 2005
Posts: 6
Location: Netherlands
Reply Quote
Hi Mike,

I'm in the same position: It is not a very important issue for us at this time. An iframe offered a nice "quick and dirty" way for us to achieve what we wanted, with the minor drawback of the page scrolling down as noted above. If I ever change our pages, I'll be sure to post the solution here.

-- Mark
Back to top
Display posts from previous:   

All times are GMT - 8 Hours