Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE7 - Object Does not Support this property or method (INDEXOF)

Status
Not open for further replies.

faiyth

Programmer
Nov 22, 2002
19
US
I did a bunch of searches but couldn't find any help.

I'm getting an error on my indexof in IE7, works fine in Firefox/etc.

here's the code:

var prefix = "";
var relative = document.getElementById('url').value;
if(relative.indexOf("http")<=0) {
prefix = "}
window.open(prefix + relative);

It is the indexOf that is causing the error. Any help rewriting this code please?
 
What is the 'url' element that you are referencing?
The only way I get this error is if the value isn't actually a string. Otherwise your code works fine in IE7.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks! That bit about the url not coming in as a string was the issue. I converted it to a string and the entire thing works. Thanks!

Here's the working code:

var prefix = "";
var relative = String(document.getElementById('url').value);
if(relative.indexOf("http")<=0) { prefix = " }
window.open(prefix + relative);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top