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
Post a Comment