View Full Version : IE not honoring named anchor tag

08-29-2008, 02:25 AM
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?

function jump () { document.write (“<a href=’#top’> </a>”);

Can someone help me clean up my act here?

08-29-2008, 04:00 AM
Does just putting #top work at all? Plus that way you wouldn't have to edit each page with the new URL.

08-29-2008, 01:17 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<title>Auto Scroll to Anchor: Cross-browser</title>
<script type="text/javascript">

onload = function(){window.location.href = "#begin_content";}

<style type="text/css">

#faux_header {height: 1000px; background-color: #f0fff0; text-align: center; padding-top: 100px; font-size: 30pt;}


<div id="faux_header">Header</div>

<a name="begin_content"></a>
Content starts here ---


08-29-2008, 11:15 PM
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.

08-30-2008, 02:35 AM
Neither of the following worked at http://jacquimorgan.tripod.com/index.htm

<SCRIPT language="JavaScript" type="text/javascript">
<!-- //<![CDATA[
onload = function () { window.location.href = "#top"; }
// ]]> -->

<SCRIPT language="JavaScript" type="text/javascript">
<!-- //<![CDATA[
function jump() {
document.write ("<a href='#top'></a>");
window.onload = jump;
// ]]> -->

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.

09-01-2008, 01:32 AM
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:

window.onload = function () { document.location = this.href += "index.html#top"; }

function jump() {
var newWin = window.open(url,'', '');
newWin.document.write("<a href='#top'> </a>");
window.onload = jump();

Was “reaching afar” with THIS.HREF but above examples were final desperate attempts.

09-03-2008, 02:45 AM
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
<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.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum