Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    IE not honoring named anchor tag

    I’ve used TRIPOD for numerous demo sites since it provides the best “freebie” hosting. With a named anchor <A name=”top” id=”top”> </A> just below where the Tripod header ad appears, I was able to jump past the ads to my content <A href="http://jacquimorgan.tripod.com/index.html#top"> go to</A> and appended the ../index.html#top to links within the site.

    Smart me! … on the MAC or Firefox PC. But ouch!

    Don’t you hate Bill Gates, Microsoft, and Internet Explorer! IE does not honor using a named anchor to go to a specific spot on a linked page. IE/PC gives all sorts of horrible notices (e.g., “Internet Explorer cannot open the site http://jacquimorgan.tripod.com/index.html#top”)

    So now, I’m trying to figure out how to add a window.document.onload function. Should this be in the form of document.write? What should the document write to jump to the #top named anchor?

    Code:
    function  jump () { document.write (“<a href=’#top’> </a>”);
    window.onload=jump:
    }
    Can someone help me clean up my act here?
    Last edited by waxdoc; 08-29-2008 at 01:51 AM. Reason: left out "guotes" for href="value"

  • #2
    Regular Coder
    Join Date
    Sep 2007
    Location
    AZ, USA
    Posts
    685
    Thanks
    6
    Thanked 46 Times in 46 Posts
    Does just putting #top work at all? Plus that way you wouldn't have to edit each page with the new URL.

  • #3
    Banned
    Join Date
    May 2005
    Location
    Midwest, U.S.
    Posts
    118
    Thanks
    1
    Thanked 26 Times in 23 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Auto Scroll to Anchor: Cross-browser</title>
    <script type="text/javascript">
    
    
    	onload = function(){window.location.href = "#begin_content";}
    
    </script>
    <style type="text/css">
    
    	#faux_header {height: 1000px; background-color: #f0fff0; text-align: center; padding-top: 100px; font-size: 30pt;}
    
    </style>
    </head>
    <body>
    
    	<div id="faux_header">Header</div>	
    
    
    	
    	<a name="begin_content"></a>
    	Content starts here ---	
    
    </body>
    </html>

  • #4
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    #top

    Binary -- not sure if you mean my attempted function or the HTML practice of marking sections on page to jump to (e.g., table of contents links). The latter works (use #hash mark before anchor name/id) and can be appended to URL link (must include page (/index.html#top).

    Cranford -- thanks. I'll try your code. i don't intend to obscure the TIPOD ads so I'll skip the CSS.

    Yes, each page will have to be modified. I've been using <a name="top" id="top"></a> for years, but wonder if "top" might be confused with reserved window _top by IE. At the bottom of the page, <a href="#top">go to page top</a> works in all browsers without a hitch.

  • #5
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    does not work

    Neither of the following worked at http://jacquimorgan.tripod.com/index.htm

    Code:
    <SCRIPT language="JavaScript" type="text/javascript">
    <!-- //<![CDATA[ 
    	onload = function () { window.location.href = "#top"; }
    // ]]> -->
    </SCRIPT>
    Code:
    <SCRIPT language="JavaScript" type="text/javascript">
    <!-- //<![CDATA[ 
    	function jump() {
    		document.write ("<a href='#top'></a>");
    		window.onload = jump;
    }
    // ]]> -->
    </SCRIPT>
    If the window.document.WRITE method were a possibility, I’d have to hunt for my notes on window.open/window.close and other details.

    It’s tempting to say “To hell with IE.” But just giving TRIPOD its ads on opening would be more logical.

  • #6
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    Still cannot get it

    Reminded by notes from “Professional JavaScript for Web Developers” (&#169; 2005) that document is only object belonging to both DOM and BOM (Browser Object Model). BOM document.write() method is used in connection with .open() and .close(). BOM location object is a property of both window and document and represents URL loaded in window … # hash mark returns content after it …
    Use location.HREF=”http://jacquimorgan.tripod.com/index.html#top”; or location.ASSIGN(”http://jacquimorgan.tripod.com/index.html#top”); to navigate to new page. Can access document object [anchors, forms, images, links] arrays by document.links[0] or document.images[“name”].src (so might be able to use document.anchors[“#top”] ?).

    Thus armed, again tried IN VAIN variations of Cranford’s code and document.write:

    Code:
    window.onload = function () { document.location = this.href += "index.html#top"; }
    Code:
    function jump() {	
    var newWin = window.open(url,'', '');
    newWin.document.open(this.href);
    newWin.document.write("<a href='#top'> </a>");
    newWin.document.close();
     }
    window.onload = jump();
    Was “reaching afar” with THIS.HREF but above examples were final desperate attempts.
    Last edited by waxdoc; 09-01-2008 at 12:47 AM.

  • #7
    Regular Coder
    Join Date
    Jul 2008
    Posts
    157
    Thanks
    9
    Thanked 13 Times in 13 Posts

    still fussing

    Simplest solution is adding manual <a href=”#top>SKIP ADS</a> so viewer can jump to <a name-“top id=”top”> </a>.

    For external or internal links to a different page, the named anchor has to be appended to the html page name [../index.html#top]. So wondered if not having INDEX.HTML as part of external link to Home page was reason Conrad’s script did not work
    Code:
     <script type="text/javascript">  onload = function(){window.location.href = "#begin_content";}  </script>
    But linking internally [<a href="contact/indexX.html">Contact</a>] from http://jacquimorgan.tripod.com/index.htm to http://jacquimorgan.tripod.com/contact/indexX.html still did not work.

    Cannot help speculating about conditional IF (document.location.href != index.html) and/or EVAL (“document.location.href” + “/index.href.#top”) or some such. However my skills are too limited to refine that thought.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •