Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

Iframes and Named Anchors

getting the js document.write() to work



4:04 am on Mar 1, 2003 (gmt 0)

10+ Year Member

I read through some previous posts and found one simular to what I am looking to do...
[webmasterworld.com ]

Mine has a slight twist to it and some comments on the above mention post from psuedo...

Here is the problem...
I am creating a website which uses some FLASH navigation and IFRAMES. I have created a page called home.html which contains a left nave menu designed in flash. The navigation is a scroller which has several links within the movie that should take the user to a page called release_notes.html

Now this page release_notes.html contains an IFRAME releasenotes.htm which has about 10 named anchors on it...

What happens is that when a user is on HOME.HTML and clicks on a link form the FLASH nav system - it does take them to the proper page release_notes.html which also properly displays the IFRAME releasenotes.htm

---> HOWEVER <---
I cannot seem to get the iframe to position the page to the proper NAME ANCHOR it was suppose to...

now... back to the above mentioned forum topic I read which contained a very simular problem... in there tedster posted some code that dynamically wrote the anchor name...

Well I followed those instructions and receieved an INVALID MARKUP which said it had a duplicate attribute... So I figured I might have done it wrong.. so I copied and pasted the code that tedster supplied and it also gave me the same INVALID MARKUP error

Any help with this situation would be so greatly appreciated...


[edited by: tedster at 5:15 am (utc) on Mar. 1, 2003]


5:40 am on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Welcome to WebmasterWorld, sherrifspaz

My apologies - I never actually tested that code. On a second look, I can see that the quote marks were messed up. Here's my second try. Let me know if it works for you:

document.write('<iframe src="faq_scroll.html\#' + anchorname + '" name="faq_scroll">LINK<\/iframe>')

If there are still problems, I will take some time later on to test that line.


1:52 pm on Mar 1, 2003 (gmt 0)

10+ Year Member

Thanks for the welcome tedster and the rapid reply... I tried the replacement code and I am still getting an INVALID MARKUP error - but - now it says its an overlapping or unclosed tag...

Any other thoughts?


5:00 pm on Mar 1, 2003 (gmt 0)

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Slighly simpler - and tested trouble free on Opera7, Explorer6, Netscape7 plus Phoenix 0.5

document.write('<iframe src="faq_scroll.html#' + anchorname + '" name="faq_scroll"></iframe>')

The quotes are a bit tricky. One little slip and the browser thinks that the document.write argument has been closed -- before you wanted it to be. The end result is writing in an incomplete HTML tag. But the above code worked for me in all cases.

Also take care to have a space between '" and name="faq_scroll". If that space isn't written in, the name attribute will bump up agains the URL in the generated HTML.

The script just concatenates three parts that are written to the HTML through document.write():

1. First half of the opening iframe tag
2. Anchorname (passed as a variable from the orphaned landing page)
3. Second half of the opening iframe tag plus the close tag


Featured Threads

Hot Threads This Week

Hot Threads This Month