SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Get URL

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get URL

    Ok so the code I had tried for this just isn't working right. So basically all i need is to insert the current page url in a link I was using document.location.href with several methods.

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Code HTML4Strict:
    <a id="current" href="#">Link</a>
     
    <script type="text/javascript">
    document.getElementById('current').href=location.href;
    </script>
    Saul

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok yes that is a much better than what I was trying but I need to put this in a existing link... the url would be something like http://www.mysite.com/go.php?var="the current page url". Thanks

  4. #4
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Something like this?

    Code HTML4Strict:
    <script type="text/javascript">
    document.getElementById('current').href='http://www.mysite.com/go.php?var='+escape(location.href);
    </script>
    Saul

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2007
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for your help that worked perfectly


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
  •