I have a question regarding URL parameters with Javascript...
Supposing I have:
<script src="http://example.com/javascript.js?param=true"></script>
How do I accept or receive the "param" parameter in the javascript.js script end.
I have a question regarding URL parameters with Javascript...
Supposing I have:
<script src="http://example.com/javascript.js?param=true"></script>
How do I accept or receive the "param" parameter in the javascript.js script end.
 
    
    Try this:
<script>
var param1var = getQueryVariable("param1");
    function getQueryVariable(variable) {
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i=0;i<vars.length;i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
          return pair[1];
        }
      } 
      alert('Query Variable ' + variable + ' not found');
    }
    </script>
 
    
    <script src="my.js?myvar=123"></script>
and inside you js file,
var myTags=document.getElementsByTagName("script");
var src= myTags[myTags.length-1].src;
var state=unescape(src).split("myvar=")[1].split("&")[0];
alert(state);
