 |

03-14-2004, 11:54 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Aug 2003
Location: Edmonton, AB, Canada
Posts: 3,406
|
|
Two browsers, one javascript error
I am noticing that when I use some javascripts that I will errors in one browser, but not another.
For instance, my front page has a 'news ticker' I just put in, and it works fine in IE, but not Firefox.
Other times, it is vice versa.
It is not with all scripts, and I realize that it due to the obviousely different versions or variations that Microsoft happens to favor, or what the f### ever, LOL, but I was wonderring if it is even worth bothering with trying to debug or tweak these scripts, or should I just get something else.
I really know pretty much zero about script language and syntax, but I obviousely have to learn sometime.
Howeverm I don't want to start surfing for answers and tutorials for specific problems like this all the time if I am just chasing a carrot, likt I finally learned with PHP type difficulties - ie. I might as well just learn from step one how to write my own stuff.
But anyhoo, is there a major concern with javascripts between the browsers?
Should it be best to just get going, or should I nake sure that I am not wasting my time by doing a tutorial that say, is version 1.1 or something when it is important to be at 1.3, okay, 1.2 at least.
Thanks, any knowledge and experiences shared is appreciated :o)
(This is funny! I went to submit this post in IE6, and I got javascript errors and it didnot submit! LOL
I had to get Mozilla out hahaha)
__________________
What I am is what I am, are you what you are, or what.
Eddie Brickel
|

03-15-2004, 07:40 AM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Jul 2003
Location: UK
Posts: 2,803
|
|
Re: Two browsers, one javascript error
Quote:
|
Originally Posted by mikmik
But anyhoo, is there a major concern with javascripts between the browsers?
|
Hi Mike,
I don't know the exact problem you're describing (coz I haven't seen the code!) but I'm guessing that your script contains conditional statements, to try and cater for different browsers.
You know yourself, with your knowledge of CSS and DOM that certain features are present in some but not in others. In JavaScript, conditional statements can test whether a certain element is present or not... if found, then the code does one thing.. if not, then it does something else!
For example, you can test for an object to differentiate one browser generation to another. IE 5+, NS6, Opera 6+ can all make use of document.getElementById, so you can use this when working with named form elements, etc.... but IE4 is restricted to document.all
The following example is a rough version of how this works in practice.
if (document.getElementById) {
// then your code would do something here
}
else if (document.all) {
// then your code would do something different here
}
else if (document.layers) {
// then your code would do something else here
}
}
Newer browsers would carry out the first set of instructions, IE4 would be detected by the second statement, and NS4 would be catered for by testing for document.layers
Anyhoo... back to your question! If you're seeing faults in IE6 but not in NS4, then you should be able to trace the problem to the condition that caters for that particular browser.
Hope that helps in some way,
Paul
|

03-15-2004, 08:33 AM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Aug 2003
Location: Edmonton, AB, Canada
Posts: 3,406
|
|
Thanks paulhiles.
Almost every single time the errors are about either "name" is undefined or
"name' is a null or void object
here, I an getting 'error line 119: marqueedata is undefined' in Moz
<ie5ticker>
<IE:Download ID="marqueedata" STYLE="behavior:url(#default#download)" />
<marquee id="externalmarquee" direction=left scrollAmount=2 style="width:50%; height:20px; background:#121212; color:#efefef; font-family:Georgia, Times New Roman, Times, serif; font-size:12px; border:1px solid #455667; padding:3px" onMouseover="this.scrollAmount=2" onMouseout="this.scrollAmount=6" src="/ass8s/pageContentText/50Tips.htm">
</marquee>
<script language="JavaScript">
<!--
function downloaddata(){
marqueedata.startDownload(externalmarquee.src,displaydata);
}
function displaydata(data){
externalmarquee.innerHTML=data;
}
window.onload=downloaddata;
-->
</script>
</ie5ticker>
So, obviousely this is a problem with the way the browsers handle the definitions in the script, like I said, they are either this type here, or else IE will return something like 'Error line 119: marqueedata is a null or void object'.
I am just using this script as an example. This is the straw that broke the camel's back, so to speak, and caused me to finally snap LOL.
I wouldn't even bother with this question in the past, it is 3rd party script, and Like I said, it almost seems like it would be easier to just learn yo write your own than debug.
This is a bad example to for obvious reasons - it is only 'meant' to work in IE ( it is called IE5TICKER for gawd sakes), even though I got it from macromedia exchange and it said it worked NS 7.1, 6, 5, 4 etc.
I couldn't get it to work in IE at first because of the <!-- if ie[IE etc etc, I can't remember how it goes, I usually use it head tags for scroll bar colors, but with that in originally,
it was generating errors in IE, and not in Moz!
I was just wondering about the general problem, and not debugging this particular script, because frankly, it is just a little 'trick' script that I couldn't care less if 1 or 2 percent of visitors are getting. I want to get busy with dhtml, DOM etc anyways, but seems that many tutes in this area are from as long ago as 1997 etc and I just like to know about if there is something in general that is to be watched. Thanks
( did U get email paul?)
__________________
What I am is what I am, are you what you are, or what.
Eddie Brickel
|

03-15-2004, 09:33 AM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Jul 2003
Location: UK
Posts: 2,803
|
|
Yeah, I think you should focus on those core disciplines you mentioned, such as the DOM, CSS and DHTML. I would drop that script if it relies on a <marquee> tag. The tag was introduced by Internet Explorer (version 4, I think), the more recent Mozilla browsers can display the scrolling, but Netscape and other older browsers will just shrug their shoulders and display static text.
I did get your email thanks, I'll get back to you soon!
Paul
|

03-15-2004, 09:53 PM
|
 |
WebProWorld 1,000+ Club
|
|
Join Date: Aug 2003
Location: Edmonton, AB, Canada
Posts: 3,406
|
|
Thanks paul, I suspected as much but expert advice is wise to consult first.
But seeing you replied, I'll use that JUST KIDDING MY FRIEND
What's gotten into me?
Anyways, you know much about the script world, thanks :O)
__________________
What I am is what I am, are you what you are, or what.
Eddie Brickel
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|