473,652 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javaScript works in IE 6.0 but not in Mozilla 2.0.10

4 New Member
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 1212
Dormilich
8,658 Recognized Expert Moderator Expert
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 Recognized Expert Moderator MVP
@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
7274
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 same problem. Internet Explorer 6 and Opera 7 have no problems with it. <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <script>document.write (window.history.length);</script>
0
8811
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8590
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.