Question : Javascript request querystring problem

I need to dynamically set an onload function based on a querystring parameter. Here is my simplified page:

<html>
<head">
 <title>Untitled Page</title>

 <script type="text/javascript">
function _init(){
var id = Request.QueryString("pg");
    if (id != "pg"){
          fb.end('ForSaleNew.aspx?cfm=del');
    }
}
 </script>

</head>
<body onload="_init();">

</body>
</html>

Thank you.

Answer : Javascript request querystring problem

Here - assuming you have  ?pg=pg or &pg=pg
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
<html>
<head>
<script type="text/javascript">
function parseQString(loc) {
  var qs = new Array();
  loc = (loc == null) ? location.search.substring(1):loc.split('?')[1];
  if (loc) {
    var parms = loc.split('&');
    for (var i=0;i<parms.length;i++) {
      nameValue = parms[i].split('=');
      qs[nameValue[0]]=(nameValue.length == 2)? decodeURIComponent(nameValue[1].replace(/\+/g,' ')):null; // use null or ""
    }
  }
  return qs;
}
function getQSParm(parm) {
  return (qs[parm])?qs[parm]:null
}

var qs = parseQString(); 
window.onload=function() {
  var id = getQSParm("pg");
  if (id != "pg"){
    fb.end('ForSaleNew.aspx?cfm=del');
  }
}

</script>
</head>
<body>
</body>
</html>
Random Solutions  
 
programming4us programming4us