javascript help!! window.location and search()

 
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions
View previous topic :: View next topic  
Author Message
jabberjawz
-


Joined: 24 Mar 2007
Posts: 1

PostPosted: Sat Mar 24, 2007 12:47 am    Post subject: javascript help!! window.location and search() Reply with quote

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>
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> General Questions All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group