For example, I have an script like this: <script src="myjs.js?lol=asd"></script>.
Is there anyway to get the lol inside the js file to alert it, for example, like we can do in PHP? Like:
var lol = $_GET['lol'];
alert(lol);
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.
Use the code from How may I reference the script tag that loaded the currently-executing script? to get a reference to the script tag:
Then you can use
thisScriptTag.srcto access itssrcattribute and parse it to get the variable you are looking for