Setting input parameters in *.html file:
1 |
<script param1="value1" param2="value2" type="text/javascript" src="js_script.js"></script> |
Getting parameters in external javascript file *.js
1 2 3 4 5 |
var params = document.getElementsByTagName('script'); var param1 = params[params.length-1].getAttribute("param1"); var param2 = params[params.length-1].getAttribute("param2"); alert('param1 = '+param1); // param1 = value1 alert('param2 = '+param2); // param2 = value2 |