Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Source | Q1041 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.