faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

7 of 15 people (47%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

Trying to use a JavaScript var in the Query String portion of the URL in a window.open

Apr 8th, 2008 17:51
ha mo, Colin Fraser, John Malechek,


If you go to this site:
http://www.math.grin.edu/~rebelsky/Tutorials/JavaScript/EdMedia97/query.html
you will find a better answer to this question than what you may
otherwise get.
After that, you might want to look at this code:
Get Query String variables in JavaScript
Author: Pete Freitag
Category: JavaScript Use Java Script to get access to the query string
<script>
function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  alert('Query Variable ' + variable + ' not found');
}
</script>
Now make a request to page.html?x=Hello
<script>
  alert( getQueryVariable("x") );
</script> 
from 
http://www.cfdev.com/code_samples/code.cfm/CodeID/59/JavaScript/Get_Query_String_variables_in_JavaScript
Cheers
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com