Kathirvel K

Go to named anchor while page (body) loads

Posted on: January 20, 2011

A named anchor inside an HTML document. Just used to navigate within the page. The name attribute specifies the name of an anchor.

Example 1: Simple HTML Scripts

Named Anchor:

<a name=”Top”> </a>

Call named anchor using href:

<a href=”#top”>Go Top</a>

Call named anchor in specific page that specific named #anchor:

<a href=”page2.htm#top”> Page2 #section</a>

Example 2: Page Load Named Anchor By Using Javascript

This need to include the function goToAnchor within head tag:

<script type=”text/javascript”>

function goNamedAnchor() {
location.href = “Page2.html#AnchorName”;


Then add this onload event to the body tag of html page:

<body onload=”goNamedAnchor();”>

Then specific the #anchor name that we want it to jump to, when the page is loaded:

<a name=”AnchorName”></a>


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: