#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    25
    Rep Power
    0

    Transfer variable from url to external javascript file


    Hi all,

    I've got my main php file which opens an external .js file and in this external .js file is a popup window script with the link to open in this popup window. Now what I want to know is how to transfer a variable from my main php file through url to this external .js file? I know how to transfer a variable to another php file.

    For example:

    In the external .js file the link to open in this new popup window is a fixed link and I want to replace it with the variable from my main php file. So if I click on the link it must transfer the variable through url to the external .js file and open it, but how do I transfer it to javascript?
  2. #2
  3. Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2000
    Location
    Enschede, The Netherlands
    Posts
    1,527
    Rep Power
    15
    This has more to do with JavaScript but ok...

    If I understand you correct you have this external .js file and a .php file where you 'create' the links you want to external .js file to handle (in the popup)? If that's the case, then just load the .js file AFTER the variables in the .php file: (basic version)
    PHP Code:
    <html>
    <head>
    <script language="JavaScript">
    <?
    echo "var url = 'http://forums.devshed.com' ";
    ?>
    </script>
    <script type="text/javascript" language="JavaScript" src="external_script.js"></script>
    </head>
    <body>
    <?

    // stuff

    ?>
    There are 10 types of people in this world - those who understand binary and those who don't...

    PHP | MySQL | DevShed Forum Search | Google Search

IMN logo majestic logo threadwatch logo seochat tools logo