|
-
Jan 26th, 2004, 09:16 AM
#1
Thread Starter
Addicted Member
JavaScript: (Why IE Sucks)
Consider the following code:
Code:
<html>
<head>
<title>Foo</title>
</head>
<body>
<select id="mySelect">
</select>
<script type="text/javascript">
myNewOption = document.createElement("option");
myNewOption.text = "foo";
myNewOption.value = 1;
document.getElementById("mySelect").add(myNewOption);
</script>
</body>
</html>
The following works in IE 6 on Windows 2000, but not in Mozilla 1.4 on Windows XP. Mozilla's complaint is that an arguement is missing from .add(). Yes, I admit that is true, but there is no element that I want the new one added before. What do I do?
Update: I've tried null as the second arguement. It works in Mozilla, but now breaks in IE. I suspect that this is the correct way, but I agree with MS, this arguement should be optional. I don't agree with MS that they shouldn't support the standard, though. I'm still looking for a common answer.
Last edited by Travis G; Jan 26th, 2004 at 03:30 PM.
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
-
Jan 26th, 2004, 12:46 PM
#2
Can't say much for Mozilla, but Opera & IE 6 work fine:
Code:
<html>
<head>
<title>Foo</title>
</head>
<body>
<select id="mySelect">
</select>
<script type="text/javascript">
myNewOption = document.createElement("option");
myNewOption.text = "foo";
myNewOption.value = 1;
document.getElementById("mySelect").options[0] = myNewOption;
</script>
</body>
</html>
-
Jan 26th, 2004, 01:44 PM
#3
Try appendChild instead of add.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jan 26th, 2004, 02:47 PM
#4
Thread Starter
Addicted Member
Code:
document.getElementById("baseSelect").options[document.getElementById("baseSelect").options.length] = newOption;
This works in both. appendChild probably works, but I have to treat newOption as a Node and not an Element, so I have to set values and stuff differently.
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
-
Jan 26th, 2004, 03:32 PM
#5
Thread Starter
Addicted Member
Code:
var inputActive = document.createElement("input");
inputActive.type = "checkbox";
inputActive.checked = Boolean(arrBases[selectIndex][3] == 1);
Code:
var inputActive = document.createElement("input");
inputActive.type = "checkbox";
if (arrBases[selectIndex][3] == 1) {
inputActive.checked = true;
}
else {
inputActive.checked = false;
}
Neither of these work in IE, either.
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
-
Jan 26th, 2004, 03:35 PM
#6
You wouldn't believe all the things that don't work in IE
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 11th, 2004, 09:14 PM
#7
I wonder how many charact
Actually, I'm surprised at all the things that DO work in IE, that don't work in Netscape.
I know its not the politically correct stance, but I truly believe since IE controls 90%+ of the browser market, that I'm FAR more concerned getting tricky scripts to run in IE, than I would ever be for the 1 or 2 users that use Netscape /Mozilla.
And since I am not running a e-commerce site, anyone that can't use it, doesn't affect our model.
-
Feb 11th, 2004, 09:33 PM
#8
Frenzied Member
I wish M$ got their CSS working properly. damn lazy bastards.
sorry for the random blurt but it had to be said.
Have I helped you? Please Rate my posts. 
-
Feb 11th, 2004, 11:28 PM
#9
-
Feb 12th, 2004, 11:27 AM
#10
Frenzied Member
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Feb 12th, 2004, 12:26 PM
#11
Thread Starter
Addicted Member
Originally posted by nemaroller
Actually, I'm surprised at all the things that DO work in IE, that don't work in Netscape.
Uhm... such as?
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
-
Feb 12th, 2004, 12:27 PM
#12
Nah, lynx sucks. Use links2
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 12th, 2004, 01:48 PM
#13
Thread Starter
Addicted Member
Odd, I have to launch IE to start a new thread here at VBForums. This is something new. The new thread image doesn't appear in Mozilla. It may be because of my user style sheet, which is supposed to not display banner ads from major distributors.
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
-
Feb 12th, 2004, 07:25 PM
#14
I wonder how many charact
Originally posted by Travis G
Uhm... such as?
Well, for one, the onkeydown event.
-
Feb 13th, 2004, 04:56 AM
#15
onkeydown works perfectly well in Mozilla.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 13th, 2004, 08:18 AM
#16
I wonder how many charact
I didn't test Mozilla (i'm sure it works there), but Netscape 6/7, it is broke.
"Unfortunately, the onkeydown event is broken in Netscape 6 and 7, so this solution does not work in those browsers."
http://www.webreference.com/programm...8/2/index.html
-
Feb 13th, 2004, 08:20 AM
#17
Frenzied Member
does that include 7.1? the newest one?
if so, that's very very silly of them.
Have I helped you? Please Rate my posts. 
-
Feb 13th, 2004, 08:33 AM
#18
Thread Starter
Addicted Member
Originally posted by CornedBee
onkeydown works perfectly well in Mozilla.
I didn't realize there was that much of a difference between Netscape and Mozilla. I guess they share Gecko and nothing more.
Travis, Kung Foo Journeyman
Web Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.5 Guide and Reference
Perl: Documentation, Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
OSS: Mozilla, MySQL (Manual)
-
Feb 13th, 2004, 08:42 AM
#19
Frenzied Member
put it this way, Mozilla always works, as long as you've got correct code and use a new version of Mozilla (or Mozilla FireFox), it'll work.
Have I helped you? Please Rate my posts. 
-
Feb 13th, 2004, 11:02 AM
#20
Let's put it this way, Netscape is usually based on outdated Mozilla builds. 6 was based on 0.9, 7 on 1.0.1, 7.1 on 1.4. Current version is 1.6.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|