Welcome to WebmasterWorld Guest from 54.196.232.162

Forum Moderators: open

Message Too Old, No Replies

Reading url using javascript

     
7:35 pm on Sep 24, 2009 (gmt 0)

New User

5+ Year Member

joined:Aug 15, 2009
posts: 19
votes: 0


Hi guys,
I'm trying to read the URL of the page using javascript, this is what I am trying and it doesnt work.

<a href="JavaScript:document.write(window.location.href);"
style="text-decoration:none;">
<img src="images/socialicons/Icons/facebook.png"
style="vertical-align: middle;" alt="Facebook"
title="share on Facebook" /> Facebook
</a>

Can someone please tell me how to do this right?

Thank you.

8:14 pm on Sept 24, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2003
posts:904
votes: 5


Try replacing the first line with:

<script type="text/javascript>
document.write('<a href="' +
window.location.href + '" style="text-decoration:none;">');
</script>