Re: setting javascript variables on url
| From: | Mark McCulligh | Date: | Fri, 06 Sep 2002 19:32:10 +0000 |
| Subject: | Re: setting javascript variables on url | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-115557@lists.php.net to get a copy of this message | ||
Use the JavaScript object "Location"
Example:
URL: http://www.www.com/index.htm?foo=bar
location.search; returns ?foo=bar
Then use the JavaScript object "String" to search the string and exact the
value.
Use the method: indexOf( ) to search the string for the character "="
Then use the method: substr( ) to get the "bar" out of the string.
Mark.
_________________________________________
Mark McCulligh, Application Developer / Analyst
Sykes Canada Corporation www.SykesCanada.com
(888)225-6824 ex. 3262
mmcculli@SykesCanada.com
----- Original Message -----
From: "Raphael Hamzagic" <raphael@tabuleiro.com>
Newsgroups: php.general
To: <php-general@lists.php.net>
Sent: Friday, September 06, 2002 3:06 PM
Subject: setting javascript variables on url
> Anyone knows if there's a way to set a javascript variable in the calling
> url. Like:
>
> http://www.www.com/index.htm?foo=bar
>
> in index.htm:
> <script language="javascript">
> <!--
> alert(foo)
> //-->
> </script>
>
> Should print "bar"
>
> Thanks
>
> Raphael
>
>