Connecting Tech Pros Worldwide Forums | Help | Site Map

javascript corrupted?

Jean Pierre Daviau
Guest
 
Posts: n/a
#1: Feb 12 '06
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



RobG
Guest
 
Posts: n/a
#2: Feb 12 '06

re: javascript corrupted?


Jean Pierre Daviau wrote:[color=blue]
> I tried this in iexplorer, mozilla, opera.
>
>
> var in = 1;[/color]

'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'.


[...]
[color=blue]
> Is it not supposed to work?[/color]

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


--
Rob
Jean Pierre Daviau
Guest
 
Posts: n/a
#3: Feb 12 '06

re: javascript corrupted?


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" <rgqld@iinet.net.au> a écrit dans le message de news:
9mPHf.382$Nv4.61555@news.optus.net.au...[color=blue]
> Jean Pierre Daviau wrote:[color=green]
>> I tried this in iexplorer, mozilla, opera.
>>
>>
>> var in = 1;[/color]
>
> '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'.
>
>
> [...]
>[color=green]
>> Is it not supposed to work?[/color]
>
> 'Work'? What result did you expect? What did you get? Error messages?
>
>
> --
> Rob[/color]


Jean Pierre Daviau
Guest
 
Posts: n/a
#4: Feb 12 '06

re: javascript corrupted?


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>


RobG
Guest
 
Posts: n/a
#5: Feb 13 '06

re: javascript corrupted?


Jean Pierre Daviau wrote:[color=blue]
> Nothing either. I think my javascript is corrupted.
>
> <SCRIPT type="javascript" language="JavaScript">[/color]

Unknown script type and language is deprecated, use:

<script type="text/javascript">
[color=blue]
> var entrant = 1;
>
> switch( entrant ){
> case 1:
> entrant = "-1-";
> break;
>
> case 2:
> entrant = 2;
> break;
>
> default:
> document.writeln(' <FONT COLOR="black">dddddddd </FONT>');[/color]

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

document.writeln(' <span style="color: black;">dddddddd </span>');

[color=blue]
> }
>
> alert(entrant);
> document.writeln('<FONT COLOR="black">ffffffffffffffffff</FONT> ');
> </SCRIPT>
> </head>
>
>
> <body>
>
>
> <SCRIPT type="javascript" language="JavaScript">[/color]

As above, error with type & remove language attribute.
[color=blue]
> <!--[/color]

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

And remove this one too.

[color=blue]
> </SCRIPT>[/color]




--
Rob
Douglas Crockford
Guest
 
Posts: n/a
#6: Feb 13 '06

re: javascript corrupted?


Jean Pierre Daviau wrote:[color=blue]
> 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?[/color]

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/
Jean Pierre Daviau
Guest
 
Posts: n/a
#7: Feb 13 '06

re: javascript corrupted?


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().


Jean Pierre Daviau
Guest
 
Posts: n/a
#8: Feb 13 '06

re: javascript corrupted?


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.


Closed Thread