homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Iframes and Named Anchors
getting the js document.write() to work
sheriffspaz




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

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

Thanks...

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

 

tedster




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

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.

sheriffspaz




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

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?

tedster




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved