Forum Moderators: open

Message Too Old, No Replies

Named links within an iFrame

Won't open to named link location

         

Balloonpilot

11:19 pm on Nov 13, 2007 (gmt 0)

10+ Year Member



Ok, I'm about to pull hair out on this one... I have a page with an iFrame on it. Through a series of dropdown menu buttons, I have opened an html document within the iFrame. From that html document inside the iFrame I want to use named links to move the user down to various parts of the document to avoid major scrolling.

Here's the code:
<a href="javascript:parent.mainBoxText.document.GetElementByID('mainBoxText').document.location.href='pircorInfo/externalAuditorText.html#Whitecourt';">Whitecourt</a>

mainboxText is the iFrame within the main page.
externalAuditorText.html is the document within the iFrame
#Whitecourt is the named link within the above document I want to go to when clicked.

I get the following error:

"Object doesn't support this property or method"

I believe it has something to do with the #Whitecourt but I'm not sure what.

Any suggestions?

Dabrowski

2:34 pm on Nov 14, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<a href="javascript:parent.mainBoxText.document.GetElementByID('mainBoxText').document.location.href='pircorInfo/externalAuditorText.html#Whitecourt';">Whitecourt</a>

The Location object is a child of what?

[edited by: Dabrowski at 2:35 pm (utc) on Nov. 14, 2007]

Balloonpilot

3:26 pm on Nov 14, 2007 (gmt 0)

10+ Year Member



It's a child of an iFrame called "mainBoxText" on the index.html page.

Dabrowski

2:22 pm on Nov 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's right, it's NOT a child of document.

Balloonpilot

2:45 pm on Nov 16, 2007 (gmt 0)

10+ Year Member



OK, I'm not seeing the forest for the trees here... how should the syntax read then?

Dabrowski

6:04 pm on Nov 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



LOL!

<a href="javascript:parent.mainBoxText.document.GetElementByID('mainBoxText').document.location.href='pircorInfo/externalAuditorText.html#Whitecourt';">Whitecourt</a>

<a href="javascript:parent.mainBoxText.document.GetElementByID('mainBoxText').location.href='pircorInfo/externalAuditorText.html#Whitecourt';">Whitecourt</a>

Spot the difference?

Balloonpilot

6:42 pm on Nov 16, 2007 (gmt 0)

10+ Year Member



D'oh... do I feel like a complete dope.

OTOH, I removed said "tree" and am still getting the same error message and it won't complete the link to the required section of the document.

Dabrowski

9:23 pm on Nov 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh hang on, spotted something else.....

<a href="javascript:parent.mainBoxText.document.GetElementByID('mainBoxText').location.href='pircorInfo/externalAuditorText.html#Whitecourt';">Whitecourt</a>

You're using parent.mainBoxText.... meaning you're trying to look up the iframe, within the iframe?

Try this one:

<a href="javascript:parent.document.GetElementByID('mainBoxText').location.href='pircorInfo/externalAuditorText.html#Whitecourt';">Whitecourt</a>

On a side note, It's just clicked what you're trying to do, when you click a link, you want the page in the current frame to change, why not just use:

<a href="pircorInfo/externalAuditorText.html#Whitecourt">Whitecourt</a>

I'm sure there's a good reason.

Balloonpilot

5:27 am on Nov 17, 2007 (gmt 0)

10+ Year Member



OK, tried the first suggestion, still get the "Object doesn't support this property or method" error.

The second method I tried earlier and while it does link to the named link within the document, for some reason, it blows away all of the header bar and most of my other graphics on the parent page.

I'm not sure if there is a CSS positioning thing going on as it appears to push everything up off the top of the window or if it's something weird with IE7.

Thoughts?

As you can probably tell, I haven't used this stuff in quite a while so I'm quite rusty.

Dabrowski

6:06 pm on Nov 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I really haven't done much cross-frame stuff, but this did ring a bell:

blows away all of the header bar and most of my other graphics on the parent page.

I believe IE is scrolling the parent page down as well as the iframe content, you may be able to fix the height of the parent window to 100% with hidden overflow, as long as your page doesn't actually require scrolling.

The other thing you could try, is setting your link to do this:

function scroll( px) { 
document.getElementsByTagName( "BODY")[0].scrollTop = px;
}

That will scroll the current window, so do it from within your frame. It's not ideal as it's hard coded, but you could get really fancy and find the <a name> target, work out it's height offset and scroll to it.

Dabrowski

5:07 pm on Nov 18, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Did you get it working?

Balloonpilot

6:33 pm on Nov 18, 2007 (gmt 0)

10+ Year Member



Haven't had a chance to try it yet... I will tomorrow AM.