SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Grabbing value from URL

    ..
    Last edited by TrainReq; Feb 6, 2007 at 19:26.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    The best thing, in my opinion, would be to do it on the server side with PHP or some other language.
    PHP Code:
    if($_GET['name']) {
      echo 
    '<div id="name" style="display:none;">' $_GET['name'] . '</div>';


  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is a long story why.. but i NEED to have it done in Javascript.. no serverside will work.

  4. #4
    SitePoint Zealot logitron's Avatar
    Join Date
    Feb 2006
    Posts
    144
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    	<head>
    		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    		<title>Some Title</title>
    		<script type="text/javascript">
    			function printLocation()
    			{
    				var loc = location.href
    				var pairs = loc.split('name=')
    				document.getElementById('response').appendChild(document.createTextNode(pairs[1]))
    			}
    		</script>
    	</head>
    	<body onload="printLocation()">
    		<div id="response"></div>
    	</body>
    </html>
    This would get it. Might need modifying for your case, but it would retrieve "John" from http://www.blah.com/index.htm?name=John or any URL that ended with "name=John".
    Patrick Smith
    PHP Programmer


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
  •