Calling URL parameters within a .js file

前端 未结 8 2159
北荒
北荒 2021-01-05 01:51

I am calling a .js file within a HTML file. On the URL to the .js file I want to include a parameter that will be accessable to the code INSIDE the .js file.

For exa

8条回答
  •  一生所求
    2021-01-05 02:27

    HTML and javascript files are static resources and will be interpreted only by the client browser, so you can't pass any query params to these values and read them inside, What you can do is dynamically generate your javascript files with params at serverside and then include it as part of the page. Or other simple way is write your js file as a php or jsp file and set the content type of the page to text/javascript and you can access all the params inside it

提交回复
热议问题