Hier ein kleiner Script-Schnipsel um get-Parameter per Javascript auszulesen:
Aufruf erfolgt mit http://www.test.de/getparams.html?test=hallo&test2=welt

<SCRIPT type="text/javascript">
<!--
HTTP_GET_VARS=new Array();
strGET=document.location.search.substr(1,document.location.search.length);
if(strGET!='')
 {
 gArr=strGET.split('&');
 for(i=0;i<gArr.length;++i)
 {
 v='';vArr=gArr[i].split('=');
 if(vArr.length>1){v=vArr[1];}
 HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
 }
 }

function GET(v)
{
if(!HTTP_GET_VARS[v]){return 'undefined';}
return HTTP_GET_VARS[v];
}
alert(GET('test') + " "+ GET('test2'));
// -->
</SCRIPT>
Werbung

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed