<script src="test.php"></script>
I want my test.php executed only when it’s from <script>, is it possible?
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.
No, that’s not possible. Stuff in the
<script>tag just gets requested as normal pages and (AFAIK) no browser sends any special headers or anything that would help you (reliably) identify it’s coming from a<script>tag.Perhaps if you explained why you want to do this, we could come up with a better solution?
I’ll go ahead and warn you that if you plan on using this to stop people from seeing or copying your JS source code, forget about it. There is just no way to do that. JS code has to be available to the browser, which means it’ll be available to the user as well.