Jump to content


Photo

How to get part of the URL


  • Please log in to reply
2 replies to this topic

#1 Lorian

Lorian
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationUnited Kingdom

Posted 27 July 2006 - 07:35 PM

Say the URL of the page the JavaScript is on is http://example.com/somepage.php?id=7, how would I get the 7 from the URL using JavaScript? Cheers.
Chris Spencer [ aka Lorian ]

[span style=\'font-size:8pt;line-height:100%\']PHP Freaks Community Member
Contact me: corrosivechris (at) gmail d0t com[/span]

#2 nogray

nogray
  • Members
  • PipPipPip
  • Advanced Member
  • 930 posts
  • LocationSan Francisco CA

Posted 27 July 2006 - 08:00 PM

If you go to my website http://www.nogray.com and download the JS library. You can access all the URL variables by including the base.js file.

after you downloading the zip file, you'll need to include this in the header
<script language="javascript" src="nogray_lib/base.js" type="text/javascript"></script> 
<script language="javascript" defer src="nogray_lib/IE_loader.js" type="text/javascript"></script> 

and your script will access the id by
_GET['id'];

Here is a link to all the base.js functions
http://www.nogray.co...ewforum.php?f=2

Here is where you can download it.
http://www.nogray.co...te/download.php

NoGray.com


#3 Lorian

Lorian
  • Members
  • PipPip
  • Member
  • 19 posts
  • LocationUnited Kingdom

Posted 27 July 2006 - 08:08 PM

That worked good, thanks.
Chris Spencer [ aka Lorian ]

[span style=\'font-size:8pt;line-height:100%\']PHP Freaks Community Member
Contact me: corrosivechris (at) gmail d0t com[/span]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users