Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-11-2009
Member
 
Join Date: Jan 2009
Posts: 67
How to find out Current Page Url with the help of JavaScript?

Hi, I am learning JavaScript. Can anyone tell me how to write a script which will provide me the Url of the web page which I am viewing currently? Please give me any suggestions or any source code through which I can achieve this? Please reply me as soon as possible.
Reply With Quote
  #2  
Old 21-11-2009
Member
 
Join Date: Apr 2008
Posts: 1,948
Re: How to find out Current Page Url with the help of JavaScript?

Hi, this is quiet simple to get the current page url with the help of java script. You just need to use the following code. Use it and enjoy it.

Current url of the page(without the hyperlink)

Code:
<SCRIPT LANGUAGE="JavaScript">
      {
       document.write(location.href);
      }
</SCRIPT>
Current url of the page(with the hyperlink)

Code:
<SCRIPT LANGUAGE="JavaScript">  
      document.write('<A HREF="' + location.href +'">');
      document.write(location.href);
      document.write('</A>');
</SCRIPT>
Reply With Quote
  #3  
Old 21-11-2009
Member
 
Join Date: May 2008
Posts: 2,008
Re: How to find out Current Page Url with the help of JavaScript?

Hi, for finding out Current Page Url with the help of JavaScript you need to use following script which I have developed for you. Just make use of it. And feel free to ask any question on this question.

Code:
<html>
<title>http://www.techarena.in (javascript:Current Page URL)</title>
<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!-- 

document.write (location.href)
document.write ("<p>")
document.write ("<a href='"+location.href+"'>Link To Current Page</a>")

// -->
</script>
</body>
</html>
Reply With Quote
  #4  
Old 21-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: How to find out Current Page Url with the help of JavaScript?

Hi, I don't know how to write script to find out current page url with the help of java script, But I have a code which can be useful to you to find out this. You can make use of it and convert it to the code of java script. Just try to use it.

Code:
if (this.markCurrent) 
{
var links = this.menu.getElementsByTagName("First");*
for (var j = 0; j < links.length; j++)
if (links[j].href == document.location.href) 
{
links[j].className = "Current Page";
break;
}
}
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to find out Current Page Url with the help of JavaScript?"
Thread Thread Starter Forum Replies Last Post
Cannot change homepage in Firefox 12 to 'use current page' Cheeru Technology & Internet 6 29-04-2012 03:21 PM
"Find in Page" unable to find words on page in Opera 10.53 CheeCha Technology & Internet 7 29-02-2012 05:11 PM
How do I get the URI of the current web page from my Drupal theme? Bambina Technology & Internet 4 28-01-2010 04:12 PM
How to get Current year with javascript Waman Software Development 2 22-05-2009 10:52 PM
Is it possible to get the current URL in my JSP page Sean J Software Development 3 19-05-2009 09:27 PM


All times are GMT +5.5. The time now is 01:55 AM.