Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[if IE 6] InnerHtml 1

Status
Not open for further replies.

ClulessChris

IS-IT--Management
Jan 27, 2003
890
GB
I have a div at the bottom of my page with the id 'topLink'
useing conditional statements I'd like to place a boookmark to the top of the page if the browser is IE6.
Have tried the following, but can't see where my error is.
I'm fairly new to Javascript.

Code:
<!--[if IE 6]>
<script type="text/javascript">
    function onLoad(){ 
	document.getElementById('topLink').innerHTML = '<p><a href="modern_history.htm#top">Return to Top of Page</a></p>';
					 }
</script>
			
<![endif]-->

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Does it work if you take out the conditional comment?

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
Thanks for your response.

I've now taken a different tack. I've left link in the div but initially hidden the div with css, and used conditional comments to make it visible.

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
your mistake was probably that you were re-using a javascript event name (onload). had you named it something unique, the error may have been resolved.

 
cLFlaVA,

On what event would the procedure then be called from?

Never knock on Death's door: ring the bell and run away! Death really hates that!
 
Chris, what cory is saying is that you created a function with the reserved name of a browser defined event. If you want something to happen once the page has completed loading, you don't create a function called onload, instead you assign a function to the onload event handler, like this:
Code:
<!--[if IE 6]>
<script type="text/javascript">
[!]window.onload = function ()[/!] {
   document.getElementById('topLink').innerHTML = '<p><a href="modern_history.htm#top">Return to Top of Page</a></p>';
};
</script>
            
<![endif]-->

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson

[small]<P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top