Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript - How to display the current URL as a link in current window?

In my current window, I need to display the current URL(document.URL) as a link. If I click that link, it will open the same page in a new window.

like image 886
Hulk1991 Avatar asked Jun 24 '13 05:06

Hulk1991


1 Answers

You can do something like this.. Maybe you can improvise on this...

<a href="#" id="link" target="_blank">Link</a>

<script type="text/javascript">
window.onload = function(){
    document.getElementById("link").href = window.location.toString();
}
</script>
like image 65
mohkhan Avatar answered Oct 18 '22 18:10

mohkhan