Page 1 of 1

Passing variables into javascript

Posted: Mon May 08, 2006 8:37 pm
by GeXus
Would something like this work?

file.js?name=tada

How would I get this variable inside the js file?

Posted: Mon May 08, 2006 8:43 pm
by feyd
I normally set Javascript global level variables either before the script is included or set them before calling the functions that are dependent on them. Similar to this:

Code: Select all

<script type="text/javascript">
  var foo = 'bar';
</script>
<script type="text/javascript" src="file.js"></script>

Posted: Mon May 08, 2006 8:50 pm
by alex.barylski
feyd wrote:I normally set Javascript global level variables either before the script is included or set them before calling the functions that are dependent on them. Similar to this:

Code: Select all

<script type="text/javascript">
  var foo = 'bar';
</script>
<script type="text/javascript" src="file.js"></script>
Jesus man...it's impossible to beat you to the punch...I swear to god your cheating...

You using some form of auto-redial/responder script which returns canned answers to questions... :P

Cheers :)

Posted: Tue May 09, 2006 1:16 am
by RobertGonzalez
I'm telling you, there is something unnatural with the speed, accuracy and correctness in his answers. It is a sight to behold.