javascript corrupted?

J

Jean Pierre Daviau

I tried this in iexplorer, mozilla, opera.


var in = 1;
switch( in ){
case 1:
in = "-1-";
break;

case 2:
in = 2;
break;

default:
document.writeln(' <FONT COLOR="black">dddddddd </FONT>');
}

alert(in);
document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');


Is it not supposed to work?

--
Jean Pierre Daviau
--
Easyphp1.8
Apache1.3.24
DEVC++, borland 5.5
windows Xp
asus p4 s533/333/133
Intel(R) Celeron (R) CPU 2.00 GHz
http://www.jeanpierredaviau.com
 
R

RobG

Jean said:
I tried this in iexplorer, mozilla, opera.


var in = 1;

'in' is a reserved word in JavaScript, do not use it for variable names.
This line causes an error message in the Firefox Javascript console of
'missing variable name'.

Change the variable name to something else and maybe it will 'work'.


[...]
Is it not supposed to work?

'Work'? What result did you expect? What did you get? Error messages?
 
J

Jean Pierre Daviau

Nothing.
A blank page with ie debugger and Frontpage debugger.

So it was hard to find....

Well, I should have remember. But I did not play with JavaScript for 4
years at least...

Thank you


RobG said:
Jean said:
I tried this in iexplorer, mozilla, opera.


var in = 1;

'in' is a reserved word in JavaScript, do not use it for variable names.
This line causes an error message in the Firefox Javascript console of
'missing variable name'.

Change the variable name to something else and maybe it will 'work'.


[...]
Is it not supposed to work?

'Work'? What result did you expect? What did you get? Error messages?
 
J

Jean Pierre Daviau

Nothing either. I think my javascript is corrupted.

<SCRIPT type="javascript" language="JavaScript">
var entrant = 1;

switch( entrant ){
case 1:
entrant = "-1-";
break;

case 2:
entrant = 2;
break;

default:
document.writeln(' <FONT COLOR="black">dddddddd </FONT>');
}

alert(entrant);
document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');
</SCRIPT>
</head>


<body>


<SCRIPT type="javascript" language="JavaScript">
<!--
alert()
document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');
//-->
</SCRIPT>
 
R

RobG

Jean said:
Nothing either. I think my javascript is corrupted.

<SCRIPT type="javascript" language="JavaScript">

Unknown script type and language is deprecated, use:

var entrant = 1;

switch( entrant ){
case 1:
entrant = "-1-";
break;

case 2:
entrant = 2;
break;

default:
document.writeln(' <FONT COLOR="black">dddddddd </FONT>');

You should update your HTML too, the font element has been deprecated
for quite a while. An HTML 4 compliant alternative is:

}

alert(entrant);
document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');
</SCRIPT>
</head>


<body>


<SCRIPT type="javascript" language="JavaScript">

As above, error with type & remove language attribute.

No need for this, just remove it.
alert()
document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');
//-->

And remove this one too.
 
D

Douglas Crockford

Jean said:
I tried this in iexplorer, mozilla, opera.


var in = 1;
switch( in ){
case 1:
in = "-1-";
break;

case 2:
in = 2;
break;

default:
document.writeln(' <FONT COLOR="black">dddddddd </FONT>');
}

alert(in);
document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');


Is it not supposed to work?

No. I ran it through JSLint, and it reported:

Error:

Problem at line 1 character 5: Expected an identifier and instead saw 'in'.

var in = 1;

'in' is a reserved word.

http://www.JSLint.com/
 
J

Jean Pierre Daviau

javascript:var entrant = 1;switch( entrant ){case 1:entrant =
"-1-";break;case 2:entrant = 2;break;default:}alert(entrant);

the previous works in the addres bar.
 
L

Lee

Jean Pierre Daviau said:
Try it here. This page does not work for me:
http://www.jeanpierredaviau.com/delme.html

It does not work for me. But I do can go on websites with javascripted pages
? ?????????????

It seems only some core javascript dont work like functions or alert().

It seems like bad code doesn't work.

1. The script tag should be:

<script type="text/javascript">

2. There is no element in your page with the id of "body", so
your reference to document.getElementById("body").offsetHeight
causes a run-time error.
 

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

Similar Threads

document.images[0].X 6
changing the barckground image 2
strange TR behavior 2
circle tracing 10
loading order 2
false popup not allowed? 5
running an ex on eMac 8
document.images 8

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top