Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1041 Can I pass a query string to a *.js source file?

You are here: irt.org | FAQ | JavaScript | Source | Q1041 [ previous next ]

I don't see the point of this. You can just set a variable before you embed the JavaScript source file:

<script language="JavaScript"><!--
var myVariable= '123';
//--></script>

<script src="http://www.mydomain.com/file.js"></script>

There is only one URL associated with a page - the documents URL. If you were to use:

<script src="test.js?123"></script>

And then in test.js:

alert('Search property = ' + location.search);

all that would happen is the JavaScript would display the search property of the current document and not the URL of the JavaScript source file.

Feedback on 'Q1041 Can I pass a query string to a *.js source file?'

©2018 Martin Webb