3

I need someone to enlighten me. I've seen this:

<script src="http://host.com/file.js?no_forms=1"></script>

What does that means? A GET parameter passed to a javascript file? Into which conditions this can be done? What kind of approach is this?

Any help would be appreciated.

4

3 回答 3

5

?no_forms=1 is just a query string parameters. i will just tell the common usage of such things.

  • Used for to avoid caching (get new updated version of JS)
  • Some sort of redirection
  • Even some application usage ideas.
于 2013-06-24T11:14:34.280 回答
2

Sometimes the parameter is used simply to prevent client side caching.

It could also be that requesting file.js is actually rewritten as a dynamic call (say script.php?file=file.js&no_forms=1) that is fetching the correct file and using the extra parameter somehow.

于 2013-06-24T11:17:30.127 回答
0

You can use this

<script src="http://host.com/file.js" no_forms="1"></script>

And

function $_GET(q,s) {
    s = s || window.location.search;
    var re = new RegExp('&'+q+'=([^&]*)','i');
    return (s=s.replace(/^\?/,'&').match(re)) ? s=s[1] : s='';
}

And get result

var noForms = $_GET('no_forms');
于 2013-06-24T11:25:58.587 回答