我可以将参数直接传递给.js文件,如何获取该值 [英] Can I pass a parameter directly to a .js file, and how do I get the value
本文介绍了我可以将参数直接传递给.js文件,如何获取该值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用单行代码将参数传递给某些JavaScript,如下所示:
I want to pass a parameter to some javascript using a single line of code, like this:
<script language="JavaScript" src="courselist.js?subj=MATH" type="text/javascript" />
在javascript文件中,如何获取参数subj的值?
Inside the javascript file, how can I get the value of the parameter "subj"?
感谢
推荐答案
只有通过访问own c $ c>< script> 元素,并分析 src
属性。
That's as far only possible by accessing "own" <script>
element in the HTML DOM and parse the src
attribute.
长篇小说,这是一篇很好的文章,详细的说明和代码示例: http://feather.elektrum.org/book/src.html
Long story short, here's a nice article with detailed explanations and code samples: http://feather.elektrum.org/book/src.html
这篇关于我可以将参数直接传递给.js文件,如何获取该值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文