jabberjawz -
Joined: 24 Mar 2007 Posts: 1
|
Posted: Sat Mar 24, 2007 12:47 am Post subject: javascript help!! window.location and search() |
|
|
i am trying to search window.location to see if it contains a specific phrase, but it (the last part) returns nothing, what am i doing wrong.. ?? please help :cry:
Code: |
<script>
//returns 11
var curlocation = "http://www.google.com" ; //window.location;
document.write( curlocation.search(/google/i) + "<br/>" ) //1
//returns location
var curlocation = window.location;
document.write( window.location + "<br/>");
//returns -1
var curlocation = "http://www.yahoo.com";
document.write( curlocation.search(/google/i) + "<br/>" );
//returns nothing.. why??
var curlocation = window.location;
document.write( curlocation.search(/google/i) + "<br/>");
//also returns nothing..
document.write( window.location.search(/google/i) + "<br/>");
//this doesnt work either
/*
var curlocation = window.location;
if curlocation.search(/google/i) {
document.write('holy moly batman!');
}
*/
</script>
|
|
|