JavaScript Vs. IE 6.0

B

beachlover

Hi

i am a novice to JavaScript - and have started learning it using online
study material and a couple of books - slowly i am getting into
practicing it at my workplace (after work hours) - yesterday i suffered
a problem using toString() toLowercase() toUppercase() etc statements
in a html file - to learn arrays containing strings. when i ran this
prog on IE 6.0 it said "This object or function not supported".

what do i do and how do i get it going again? is this a conflict
between IE and JavaScript and if so, what could be the solution?

please help

thanx
raj
 
M

Martin Honnen

beachlover wrote:

yesterday i suffered
a problem using toString() toLowercase() toUppercase() etc statements
in a html file - to learn arrays containing strings. when i ran this
prog on IE 6.0 it said "This object or function not supported".

what do i do and how do i get it going again?

It will give you a line number and then you have to check that line in
your code to correct the error, for instance strings have methods named
toLowerCase
and
toUpperCase
but not ones named toLowercase or toUppercase.
So make sure when you use JavaScript and properties or methods of
objects that you check the case of letters, it matters with JavaScript.
 
L

Luca Giannoni

javascript is case sensitive so you have to use toLowerCase and toUpperCase

bye
Luca
 
B

beachlover

Hey Martin:
thanks for your quick response.. however, could you pls diagnose what
is wrong with the following code and where:

it shows an error:
----------------------------------------------------------------------
Line: 25
Char: 1
Error:"Object doesnt support this property or method"
Code: 0
----------------------------------------------------------------------
<HTML>
<head>
<title> The array object </title>
</head>
<body>
<br>
<h1 align="center">The array object </h1>
<hr>
<Script language = "JavaScript">
myArray=new Array (1,2,3,4,5,6,7,8,9,10,0)
document.write("<pre>")
document.write("myArray.toString()\t:\t\t")
document.write(myArray.toString()+"<BR>")
document.write("myArray.join('|')\t:\t\t")
document.write(myArray.join("|")+"<BR>")
document.write("myArray.reverse()\t:\t\t")
document.write(myArray.reverse()+"<BR>")
document.write("myArray.sort()\t\t:\t\t")
document.write(myArray.sort()+"<BR>")
document.write("</pre>")
document.write("<hr>")
myArray2=new Array ("This is first string. This is second string.")
document.write("<pre>")
document.write("myArray2.toLowerCase()\t\t:")
document.write(myArray2.toLowerCase()+"<BR>")
document.write("myArray2.toUpperCase()\t\t:")
document.write(myArray2.toUpperCase()+"<BR>")
document.write("myArray2.substring(8)\t\t:")
document.write(myArray2.substring(8)+"<BR>")
document.write("myArray2.substring(4,12)\t\t:")
document.write(myArray2.substring(4,12)+"<BR>")
document.write("myArray2.split('is')\t\t:")
document.write(myArray2.split('is')+"<BR>")
document.write("myArray2.charAt(9)\t\t:")
document.write(myArray2.charAt(9)+"<BR>")
document.write("myArray2.charCodeAt(2)\t\t:")
document.write(myArray2.charCodeAt(2)+"<BR>")
document.write("myArray2.indexOf('second')\t\t:")
document.write(myArray2.indexOf('second')+"<BR>")
document.write("</pre>")
</script>
</body>
</html>

thanks
raj
 
R

RobG

beachlover said:
Hey Martin:
thanks for your quick response.. however, could you pls diagnose what
is wrong with the following code and where:

it shows an error:
----------------------------------------------------------------------
Line: 25
Char: 1
Error:"Object doesnt support this property or method"
Code: 0
----------------------------------------------------------------------

Which points to exactly where the error is (see below).

[...]
<Script language = "JavaScript">

The language attribute is depreciated, type is required:

<script type="text/javascript">

You're probably better off keeping tags either all uppercase or all
lowercase, it's not really important for HTML but when (if?) a
transition to XHTML takes place it may be significant.

[...]
myArray2=new Array ("This is first string. This is second string.")
document.write("<pre>")
document.write("myArray2.toLowerCase()\t\t:")
document.write(myArray2.toLowerCase()+"<BR>")

You can get away with omitting semi-colons ';' in JavaScript but it
isn't a good idea. Much better to put them all in where they are
supposed to be.

This above is line 25. You are trying to call the toLowerCase method of
the array 'myArray2'. But arrays don't have a toLowerCase method,
strings do. You have two choices:

1. Declare myArray2 as a string:

myArray2 = "This is first string. This is second string.";

in which case it should perhaps be called 'aString' to avoid confusion
(I really loath anything called 'my' whatever).

2. Use a reference to an item within myArray that is a string:

document.write( myArray2[0].toLowerCase() + "<BR>" )

But I can't see the point of using an array when a simple string will do
the job.

You can also remove a heap of code by using only one document.write
statement for each block of stuff:

<script type="text/javascript">
myArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0];
document.write(
"<pre>",
"myArray.toString()\t:\t\t",
myArray.toString()+"<BR>",
"myArray.join('|')\t:\t\t",
myArray.join("|")+"<BR>",
"myArray.reverse()\t:\t\t",
myArray.reverse()+"<BR>",
"myArray.sort()\t\t:\t\t",
myArray.sort()+"<BR>",
"</pre>" + "<hr>"
);
aString = "This is first string. This is second string."
document.write(
"<pre>",
"aString.toLowerCase()\t\t:",
aString.toLowerCase()+"<BR>",
"aString.toUpperCase()\t\t:",
aString.toUpperCase()+"<BR>",
"aString.substring(8)\t\t:",
aString.substring(8)+"<BR>",
"aString.substring(4,12)\t\t:",
aString.substring(4,12)+"<BR>",
"aString.split('is')\t\t:",
aString.split('is')+"<BR>",
"aString.charAt(9)\t\t:",
aString.charAt(9)+"<BR>",
"aString.charCodeAt(2)\t\t:",
aString.charCodeAt(2)+"<BR>",
"aString.indexOf('second')\t:",
aString.indexOf('second')+"<BR>",
"</pre>"
);
</script>


[...]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top