...

View Full Version : indexOf() not working



bubbles19518
07-30-2008, 04:37 AM
<script language="JavaScript">
if(window.location.indexOf('http://google.com') == -1) {
window.location = 'http://google.com';
}
</script>


The purpose of the script is to see if the user is at google.com, if not they are redirect them to google.com, otherwise not. Its not working and I have no idea why. Help please.

rangana
07-30-2008, 04:41 AM
You missed highlighted:


if(window.location.href.indexOf('http://google.com') == -1)


Without the one in red, your script will still work.

bubbles19518
07-30-2008, 04:48 AM
thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum