Can you pass key-value pairs to a JavaScript file like that:
<script type="text/javascript" src="http://www.example.com/script.js?key=value"></script>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not easily, unless you want them to be processed by server-side code that generates Javascript.
However, you can define variables in an earlier
scriptblock as parameters.For example:
You can then use the
keyvariable inscript.jsjust like any other variable.EDIT: As Upper Stage pointed out, it would be a better idea to put the parameters inside their own namespace.
For example:
You could then write
MyScriptParameters.param2inscript.js(Or in any other script on the page)