jquery - Fetching query string parameters passed in a javascript file -


i have used this tutorial create js based widget. 1 thing need pass query string parameters in js file. tried document.location.href gave url of page widget placed(which quite obvious)

code given below:

<script src="http://example.com/widget.js?id=2" type="text/javascript"></script>     <div id="widget"></div> 

i need fetch id=2 can pass further.

thanks

if give script id can write:

<script src="http://example.com/widget.js?id=2" id="myscript" type="text/javascript"></script> <div id="widget"></div>  <script> var myscript = document.getelementbyid('myscript'); var src= myscript.getattribute('src'); //get id src based on parameter using regular expression </script> 

Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -