You may append id attribute to script tag like this:
<script src="/file.js?query=string" id="query"></script>
and then call it:
console.log(document.getElementById("query").src.split("query=")[1]);
A small working sample code is below:
<html>
<head>
<script src="aaa.js?query=abcd" id="query"></script>
</head>
<body></body>
</html>
Here is the code inside of aaa.js:
window.onload=function(){
alert(document.getElementById("query").src.split("query=")[1]);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…