.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal

Home >> Code Snippets >> Javascript >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to set text and navigate url property of hyperlink control from javascript

Posted By:shankey       Posted Date: July 26, 2011    Points: 40    Category: Javascript    URL: http://www.dotnetspark.com  

How to set text and navigate url property of hyperlink control from javascript

Hi All,

This article will help you to understand how to set Text and NavigateURL property of hyperlink control.

This is bit easy on server site but when you need to do on client side then you need to set proper properties to work in all the browsers.

To set these two properties from client side i.e. javascript then do following step:

var hyp = document.getElementById('<%= Hyp.ClientID %>');

Once you get the control on client side all you need to set innerHTML and href property of hyperlink control. Both innerHTML and href are synonyms of Text and NavigateURL property on client side.
hyp.innerHTML = 'New Text';
hyp.href = 'http://www.dotnetspark.com'
To set the text from client side set innerHTML and to set the navigate url set the href property of object.

This both property works in IE8,Firefox and safari.


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend