www.webdeveloper.com
Results 1 to 4 of 4

Thread: Javascript Question On Displaying Page URL

  1. #1
    Join Date
    Mar 2009
    Posts
    27

    Question Javascript Question On Displaying Page URL

    Hello,
    Does anyone know how to display the current page URL in a simple textbox?

    It would be great if someone could please answer this question!

    I have been searching for the answer for this question for a while now. Can anyone help me please?

  2. #2
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    location object contain information about the current URL. so, your case you are interested in location.href
    http://www.w3schools.com/htmldom/dom_obj_location.asp

  3. #3
    Join Date
    Mar 2009
    Posts
    27

    Thanks, but there is a bit more to it

    Thanks for the try, but I need it to be displayed in a textbox?

  4. #4
    Join Date
    May 2006
    Location
    Odenton, MD
    Posts
    1,449
    assuming the textbox contain an id, you would refer to it with getElementById and then set the value property to location.href
    Code:
    <input type='text' id='url' />
    <script type='text/javascript'>
    document.getElementById('url').value = location.href;
    </script>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles