Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

OnMouseOver font size wont change in FireFox.

Posted on 2008-10-05
10
704 Views
Last Modified: 2012-05-05
Hi.
I have this code that works in IE but not in FFox :

onmouseover="getElementById('101').style.color='#286EA0'; getElementById('101').style.fontSize='18';"

onmouseout="getElementById('101').style.color='#808080'; getElementById('101').style.fontSize='12';">

-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~

Font color is theonly thing i can change in FFox...
How can i make the font size work ?
0
Comment
Question by:CodedK
  • 5
  • 5
10 Comments
 
LVL 29

Expert Comment

by:Badotz
ID: 22644223
Try using:

document.getElementById

instead of only:

getElementById
0
 
LVL 16

Author Comment

by:CodedK
ID: 22644638
No, nothing.
I've also tried using a script, function... But the only things Firefox can do is change colors...
0
 
LVL 29

Expert Comment

by:Badotz
ID: 22645643
If you put the font sizing before the color changing, what happens?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 16

Author Comment

by:CodedK
ID: 22645682
If i put only font sizing alone ... nothing...
If i put it first also nothing.
Anything else except font color wont work !
0
 
LVL 29

Expert Comment

by:Badotz
ID: 22645921
This link discusses a different approach:

http://www.javascriptkit.com/dhtmltutors/externalcss3.shtml
0
 
LVL 16

Author Comment

by:CodedK
ID: 22647346
Sorry Badotz, i'm not that advanced.
I cant understand how to implement this.
0
 
LVL 29

Accepted Solution

by:
Badotz earned 200 total points
ID: 22648534
Here is code that works in IE and FF. Copy it into your page and make any necessary changes.


<script type="text/javascript">
 
var css = document.styleSheets[0]; // get the FIRST stylesheet
var rules = css.cssRules ? css.cssRules : css.rules; // x-browser CSS rules
 
var mode = 0; // swap indicator
// -------------------------------------
 
function find_rule(rule) {
    for (var i = 0; i < rules.length; i++) {
        if (rules[i].selectorText.toLowerCase().indexOf(rule) >= 0) { // find rule
            return rules[i];
        }
    }
     return null;
}
// -------------------------------------
 
function change_rule(new_rule) {
    var old_rule = find_rule(new_rule.rule);
    if (old_rule != null) {
        old_rule.style[new_rule.attr] = new_rule.valu; // apply new css
    }
}
// -------------------------------------
 
function change_css(new_rule) {
    for (var i = 0; i < new_rule.length; i++) {
        change_rule(new_rule[i]); // apply all new css
    }
}
// -------------------------------------
 
 
function css_hack() {
/*
 Presumably, you have CSS to set the font size and color. Let's call this rule 'base'.
 It looks like this:
 
 base { color: #808080; font-size: 12px; font-style: normal; }
 
You change the base rule like this:
 
 var new_rule = 
     [
         {'rule':'base','attr':'color', 'valu':'#286ea0' },
         {'rule':'base','attr':'fontSize', 'valu':'18px'; }
     ];
     change_css(new_rule);
 */
	var new_rule = [];
	
	if (mode == 0) { /* 'normal' mode */
		new_rule.push({'rule':'base','attr':'color','valu':'#ff0000'});
		new_rule.push({'rule':'base','attr':'fontSize','valu':'48px'});
		new_rule.push({'rule':'base','attr':'fontStyle','valu':'normal'});
	}
	else { /* changed mode */
		new_rule.push({'rule':'base','attr':'color','valu':'#0000ff'});
		new_rule.push({'rule':'base','attr':'fontSize','valu':'14px'});
		new_rule.push({'rule':'base','attr':'fontStyle','valu':'italic'});
	}
	mode = ((mode == 0) ? 1 : 0);
	change_css(x);
	document.getElementById('cmd_css').value = 'Change CSS (' + mode + ')';
}
 
</script>

Open in new window

0
 
LVL 16

Author Comment

by:CodedK
ID: 22648733
Thank you very much for your time and effort.
Give me some time to apply this and aword the points :)
0
 
LVL 16

Author Closing Comment

by:CodedK
ID: 31503148
Thank you Badotz.

Sorry for the delay. I didnt find any time to check it earlier ... :)
Anyway thank you very much.
0
 
LVL 29

Expert Comment

by:Badotz
ID: 22724782
No worries - glad to help.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question