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

前端 未结 4 1392
一整个雨季
一整个雨季 2020-12-19 08:31

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 b

4条回答
  •  失恋的感觉
    2020-12-19 09:03

    This method should only be used if the varaibles would determine what JavaScript code was loaded (e.g., with the request being processed by PHP, dynamically building the JS file).

    If you want to pass information to JavaScript code, use functions or variables in the code after it is loaded.

提交回复
热议问题