473,320 Members | 2,202 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

javaScript works in IE 6.0 but not in Mozilla 2.0.10

Hi Folks,

I have two issues:

1- I have written following code a code that works in IE but not in firefox. Please see code below. JavaScript version is 1.3. Both browsers should be able to run the script?

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
  2. <html>
  3. <style type="text/css">
  4. table {border-collapse: collapse; }
  5. TEXTAREA {width:300px; height:200px; border: 0; overflow:hidden;}
  6. td {width:30px;padding: 0; margin: 0; border: 1px solid gray;}
  7. </style>
  8.  
  9. <script Language="javascript">
  10.  
  11. function setBorderBold(x)
  12. {
  13.  document.getElementById(x).style.border="0.20em black solid";
  14. }
  15.  
  16. function setBorderToStandard(x)
  17. {
  18.  document.getElementById(x).style.border="0.05em solid gray";
  19. }
  20.  
  21.  
  22. </script>
  23.  
  24. <body>
  25. <form>
  26. <table bordercolor="gray"><tr><td id="myid1"><TEXTAREA name="thetext" id="textarea1" onfocus="setBorderBold('myid1')" onblur="setBorderToStandard('myid1')"></textarea></td><td id="myid2"><TEXTAREA name="thetext" maxwidth="400em" id="textarea1" onfocus="setBorderBold('myid2')" onblur="setBorderToStandard('myid2')"></textarea></td></tr></table>
  27. </form>
  28. </body>
  29. </htm>
  30.  
2- Second issue is just a genaral question: which javaScript version is the best to use cosidering the diversity of browsers and incompatibility problems?

Or is there something like a "javaScript Plugin" for browsers, so that each browser could run any version of Javascript provided the plugin is installed?Maybe a silly question, but am a beginner :)

Regards

Bu
Nov 27 '08 #1
2 1201
Dormilich
8,658 Expert Mod 8TB
1 - you should validate your html, this will certainly solve most problems. (e.g. use <script type="text/javascript">)

2 - don't rely on javascript version. the easiest way is to check for the existance of the function/feature you want to use.

example
Expand|Select|Wrap|Line Numbers
  1. if (document.addEventListener()) {
  2.   // some code
  3. }
  4. else if (document.attachEvent) {
  5.   // some code for IE
  6. }
  7. else {
  8.   // any error handling (silent fail)
  9. }
regards
Nov 28 '08 #2
acoder
16,027 Expert Mod 8TB
@wannasee
If only, if only! Unfortunately, browsers don't always follow standards, some add their own proprietary features, and there are many bugs. Welcome to the frustrating world of cross-browser coding. As Dormilich pointed out, you don't specify the JavaScript version (though JavaScript does have versions). If you want to support older browsers that may not support the method that you want to use, use object/feature detection to avoid errors.
Nov 28 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.