Forum Moderators: open
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?
<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?
<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.
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.
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.