0

Would like to copy the current url into a text box and create a prompt before it

I have class assigned to the text box in the form

Is there a way to use something close to the following to make this work?

$('.txtbox').val(window.location.pathname); 

Thanks

user1673622
  • 61
  • 1
  • 2
  • 1
    [Request Address in Javascript](http://stackoverflow.com/questions/1029387/request-address-in-javascript?lq=1) – j.w.r Sep 16 '12 at 19:08

1 Answers1

0

This should work:

$('.txtbox').val(window.location.href); 
jimp
  • 16,999
  • 3
  • 27
  • 36
  • Doesn't seem to take - do I need to account for the value="" to make it pre-fill correctly? – user1673622 Sep 16 '12 at 20:04
  • I'm not sure what you mean. It is working well for me. Look at this example: http://jsfiddle.net/jimp/5jRVU/ Are you possibly trying to execute that script before the exists in the page? – jimp Sep 16 '12 at 20:19