Javascript Argument Handling
by admin on Oct.31, 2008, under Coding
Problem:
yourhappyhtml.html?argument=xxx
Solution:
function d(){var x=window.location.search.split(‘?’);if(isset(x[1])){setTimeout(“z(“+x[1]+”)”,200);}}
Explanation:
this will call a function z that will show a specific hidden div depending on the parameter sent, due random crappyness on onload function i added a timer as a workaround, to call this in a bare way you should do ?number , and nothing else, x[0] is always null, isset() is:
function isset(v) { return ((v == undefined) || (v == “”)) ? false : true; }
to send more than one argument you will need to split the “=” as well inside the x[1], since javascript will take the whole query as a variable.