[Javascript] Re: "Object Expected" Error
Bludshogun at aol.com
Bludshogun at aol.com
Fri May 3 19:09:24 CDT 2002
--- In javascript at y..., Rodney Myers <rodney at a...> wrote:
> Try
> if (string.indexOf("<TEXTAREA")>-1)
>
> Your current expression
> string.indexOf("<TEXTAREA")
> gives the value -1 because there is no "<TEXTAREA"
> -1 is TRUE not FALSE!
> Only 0 is false.
>
> hth
>
> Rodney
>
Well thanks for pointing that out but it doesn't solve my problem. I'd like
if someone could plug this code into IE5.5 and tell me what happens. It seems
really simple. It gets to that line:
string = string.substring(0,indexOf("<TEXTAREA"))
it says function [objected expected char 1,. . .] at this line. I've tried
using other variable names for "string". I've tried declaring preSTRvariable
with a strict var preSTRvariable = new String() it always gets object
expected.
code:
<html>
<head>
<title>Function Testing</title>
<script language="JavaScript">
function removeValue(string) {
if (string.indexOf("<TEXTAREA")) {
//line 17 follows
string = string.substring(0,indexOf("<TEXTAREA")) +
string.substring(indexOf("</TEXTAREA>",string.length))
return string
}
return string
}
function robot() {
preSTRvariable = document.body.innerHTML
preSTRvariable = removeValue(preSTRvariable)
}
</script>
</head>
<body>
<form>
<button style="background-color: #FFFFFF" onClick="robot
()">Click</button>
</form>
</body>
</html>
More information about the Javascript
mailing list