Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 5 characters in body
Source Link
Sinan Ünür
  • 118.3k
  • 15
  • 201
  • 347

Pretty straightforward, I've got a JS script that's included on many different sites and needs to have parameters passed to it.

It would be damned useful if those could be passed via the URL, eg:

<script type="text/javascript" src="htt src="http://path.to/script.js?var1=something&var2=somethingelse"></script> 

Yes, you can still pre-populate variables, in a separate script tag, but it's a smidge messy and less easy to pass around:

<script type="text/javascript">var1=something; var2=somethingelse</script> <script type="text/javascript" src="httsrc="http://path.to/script.js"></script> 

Pretty straightforward, I've got a JS script that's included on many different sites and needs to have parameters passed to it.

It would be damned useful if those could be passed via the URL, eg:

<script type="text/javascript" src="htt://path.to/script.js?var1=something&var2=somethingelse"></script> 

Yes, you can still pre-populate variables, in a separate script tag, but it's a smidge messy and less easy to pass around:

<script type="text/javascript">var1=something; var2=somethingelse</script> <script type="text/javascript" src="htt://path.to/script.js"></script> 

Pretty straightforward, I've got a JS script that's included on many different sites and needs to have parameters passed to it.

It would be useful if those could be passed via the URL, eg:

<script type="text/javascript"  src="http://path.to/script.js?var1=something&var2=somethingelse"></script> 

Yes, you can still pre-populate variables, in a separate script tag, but it's a smidge messy and less easy to pass around:

<script type="text/javascript">var1=something; var2=somethingelse</script> <script type="text/javascript" src="http://path.to/script.js"></script> 
Source Link

Is there any analogue in Javascript to the __FILE__ variable in PHP?

Pretty straightforward, I've got a JS script that's included on many different sites and needs to have parameters passed to it.

It would be damned useful if those could be passed via the URL, eg:

<script type="text/javascript" src="htt://path.to/script.js?var1=something&var2=somethingelse"></script> 

Yes, you can still pre-populate variables, in a separate script tag, but it's a smidge messy and less easy to pass around:

<script type="text/javascript">var1=something; var2=somethingelse</script> <script type="text/javascript" src="htt://path.to/script.js"></script>