I'm not sure if I have the jargon for asking this question not being a web developer but please bear with me.
I want to send parameters to a client side HTML page (just a file on a disk no web server involved). My initial attempt was to use a query string and then parse it from window.location.href
but instead of the query string being passed to the page I get a file not found error.
Is it possible to do what I'm attempting?
I'm not sure if I have the jargon for asking this question not being a web developer but please bear with me.
I want to send parameters to a client side HTML page (just a file on a disk no web server involved). My initial attempt was to use a query string and then parse it from window.location.href
but instead of the query string being passed to the page I get a file not found error.
Is it possible to do what I'm attempting?
Share Improve this question edited Jun 15, 2009 at 18:23 Motti asked Jun 15, 2009 at 6:17 MottiMotti 115k56 gold badges194 silver badges273 bronze badges3 Answers
Reset to default 10You might want to pass parameters using the # instead of ? on local files.
Firefox and Chrome will let you do this. But IE won't. IE returns file not found like you said.
file:///D:/tmp/test.htm?blah=1
<script language='javascript'>
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
alert(getUrlVars());
</script>
do you mean you want something like
window.location.search
http://developer.mozilla.org/En/DOM/Window.location
search: the part of the URL that follows the ? symbol, including the ? symbol.