Would something like this work?
file.js?name=tada
How would I get this variable inside the js file?
Passing variables into javascript
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
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>-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Jesus man...it's impossible to beat you to the punch...I swear to god your cheating...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>
You using some form of auto-redial/responder script which returns canned answers to questions...
Cheers
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA