Get variable value from embeded object

ساخت وبلاگ
Hi Guys

I have a call to a JS file on a page
Code:

<script type="text/javascript" src="test.js"></script>
How can I add variables to be passed to the script ?

I assume test.js?VAR=1 in the source wont work..

But if it DOES work how can I get the script to then read the variable value being passed to it /?

I came across
Code:

function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}

However that is getting the var data from the address bar url string which isnt what I want
CodingForums...
ما را در سایت CodingForums دنبال می کنید

برچسب : نویسنده : codingforums بازدید : 128 تاريخ : يکشنبه 15 مرداد 1396 ساعت: 8:34