Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2006
    Posts
    28
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Simple Help with Variables

    Hello everybody,

    I need some small help with GET Variables in JS.

    I'll explain this with an example.


    In an HTML file, i have the following code :
    Code:
    <script type="javascript" src="http://anothersite.com/file.js?name=Darkman"></script>
    The JS file is as follows :
    Code:
    document.write("The name is '+name+'");
    Now, how do i detect and store this "Darkman" in the "name" variable ?


    Thanks,

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    You can't do that with .js file. If the javascript file is a file that has an extension of .asp, .php or any server-side language you are using and has a response type set to "text/javascript", then you can easily retrieve the URL querystring using the server-side language.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

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