Results 1 to 4 of 4

Thread: How to find out Current Page Url with the help of JavaScript?

  1. #1
    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.

  2. #2
    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>

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    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>

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    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;
    }
    }

Similar Threads

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

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,716,301,761.92448 seconds with 17 queries