Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > IE, Opera, Netscape, & Mozilla

Reply
Thread Tools

IE, Opera, Netscape, & Mozilla

 
 
jfancy-Transport Canada
Guest
Posts: n/a
 
      05-31-2005
This code needs to be changed so that it is compatible with other
browsers like Opera, Netscape, and Mozilla.

{
s=a[i].currentStyle.fontSize+'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].currentStyle.fontSize)+factor+s;
}


In particular, the "currentStyle" and "style" i would imagine needs to
be changed to something and i'm not sure how to go about doing that.

Any Suggestions...?

 
Reply With Quote
 
 
 
 
Daniel Kirsch
Guest
Posts: n/a
 
      06-01-2005
jfancy-Transport Canada wrote:
> This code needs to be changed so that it is compatible with other
> browsers like Opera, Netscape, and Mozilla.
>
> {
> s=a[i].currentStyle.fontSize+'';
> s=Right(s,2);
> a[i].style.fontSize = parseInt(a[i].currentStyle.fontSize)+factor+s;
> }
>
>
> In particular, the "currentStyle" and "style" i would imagine needs to
> be changed to something and i'm not sure how to go about doing that.
>
> Any Suggestions...?


I use a function to get a defined style of an element:

function getStyle(aElm, aStyle) {
var lStyle;
try {
if (aElm && typeof aElm.style != "undefined")
lStyle = aElm.style[aStyle];
}
catch(e) {}

var retVal;

if (lStyle)
retVal = lStyle;
else {
// Mozilla
if (document.defaultView) {
aStyle = aStyle.replace(/([A-Z])/g, "-$1").toLowerCase();
retVal =
aElm.ownerDocument.defaultView.getComputedStyle(aE lm,"").getPropertyValue(aStyle);

// some elements might not have a defined value (eg. images)
if (retVal == "auto") {
if (aStyle == "width")
retVal = aElm.offsetWidth;
else if (aStyle == "height")
retVal = aElm.offsetHeight;
}
}
// IE
else if (aElm.currentStyle) {
retVal = aElm.currentStyle[aStyle];
}
else
return null;
}
return retVal;
}

Your script block might then look like this (note, I don't know what
"Right" does and "factor" is so if you don't get it working, you might
show us some more code):

s = getStyle(a[i],"fontSize");
var s_new=Right(s,2);
a[i].style.fontSize = parseInt(s)+factor+s_new;

Daniel
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mozilla pieces versus Mozilla Suite Doug Chadduck Firefox 40 02-12-2006 10:27 PM
Windows Media opening outside Mozilla not in a Mozilla Window Jim Firefox 3 12-17-2005 02:00 AM
CSS Mozilla: Make Mozilla not ignore height style of an inline element Henri HTML 9 02-22-2005 06:08 PM
My CUSTOM Versions Of Mozilla Fiorefox & Mozilla Thunderbird Norvin Adams III Firefox 6 07-13-2004 03:26 PM
mozilla 1.5 from mozilla 1.4 Disco Firefox 6 11-07-2003 04:34 PM



Advertisments