473,788 Members | 2,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change mozilla className onfocus

35 New Member
i need a way of changin a class name on focus which works in both ie and mozilla style browsers.....i think i read that className doesnt work in mozilla because its a reserved term or something....is there something similar which i can apply to an oFocus which is browser compatible and does not require script.

thanks
Mar 24 '08 #1
7 3118
gits
5,390 Recognized Expert Moderator Expert
that seems to be a javascript question ... but setting className works in both, IE and Mozilla/FF ...

show your code in case you have problems with it.

kind regards
Mar 25 '08 #2
ukfusion
35 New Member
Heres the page code....i think my problem is to do with the way im specifying which element to change.... i.e. menu1.className ='menub'.

but please note i want to achieve this WITHOUT script hence the post in css/html forum

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6. <style type="text/css">
  7. <!--
  8. .menub {
  9.     overflow: hidden;
  10.     width: 100px;
  11.     height: 29px;
  12.     clear: both;
  13.     float: left;
  14. }
  15. .menuc {
  16.     overflow: visible;
  17.     width: 100px;
  18.     height: auto;
  19.     clear: both;
  20.     float: left;
  21. }
  22. a.menu3:link, a.menu3:active, a.menu3:visited {
  23.     font-family: Arial, Helvetica, sans-serif;
  24.     color: #FFFFFF;
  25.     text-decoration: none;
  26.     background-color: #cccccc;
  27.     display: block;
  28.     padding: 5px;
  29. }
  30. a.menu2:link {
  31.     font-family: Arial, Helvetica, sans-serif;
  32.     color: #FFFFFF;
  33.     text-decoration: none;
  34.     background-color: #666666;
  35.     display: block;
  36.     padding: 5px;
  37. }
  38. a.menu2:hover,a.menu2:active,a.menu2:visited {
  39.     background-color: #0099FF;
  40.     font-family: Arial, Helvetica, sans-serif;
  41.     color: #FFFFFF;
  42.     text-decoration: none;
  43.     display: block;
  44.     padding: 5px;
  45. }
  46. -->
  47. </style>
  48. </head>
  49.  
  50. <body>
  51.  
  52. <div class="menub" id="menu1">
  53. <li><a href="#" class="menu3" onfocus="menu1.className='menuc'" onblur="menu1.className='menub'">Link1a</a></li>
  54. <li><a href="#" class="menu2">Link2a</a></li>
  55. <li><a href="#" class="menu2">Link3a</a></li>
  56. <li><a href="#" class="menu2">Link4a</a></li>
  57. <li><a href="#" class="menu2">Link5a</a></li>
  58. </div>
  59. <div class="menub" id="menu2">
  60. <li><a href="#" class="menu3" onfocus="menu2.className='menuc'" onblur="menu2.className='menub'">Link1b</a></li>
  61. <li><a href="#" class="menu2">Link2b</a></li>
  62. <li><a href="#" class="menu2">Link3b</a></li>
  63. <li><a href="#" class="menu2">Link4b</a></li>
  64. <li><a href="#" class="menu2">Link5b</a></li>
  65. </div>
  66. </body>
  67. </html>
Mar 25 '08 #3
gits
5,390 Recognized Expert Moderator Expert
that IS javascript:

Expand|Select|Wrap|Line Numbers
  1. onfocus="menu1.className='menuc'"
and i don't know a way without using javascript ... at least no cross-browser way ...

kind regards
Mar 25 '08 #4
ukfusion
35 New Member
that IS javascript:

Expand|Select|Wrap|Line Numbers
  1. onfocus="menu1.className='menuc'"
and i don't know a way without using javascript ... at least no cross-browser way ...

kind regards
ahh ok....so is any use of the DOM javascript?...i could achieve what i want in css using the hover class....but id rather get it onclick or focus.

(sorry to be a pain...but i disabled javascript on my browser and all the functions worked fine without any problems so does menu1.className ='menuc' still use javascript?)

so theres basically no way to change a class name without script?

cheers
Mar 25 '08 #5
drhowarddrfine
7,435 Recognized Expert Expert
Correct. html/css are not programming languages so they cannot change properties, elements or attributes.
Mar 25 '08 #6
gits
5,390 Recognized Expert Moderator Expert
without javascript you can do the following in newer mozilla/FF versions:

[HTML]<style type="text/css">
a:focus {
color: green;
}
</style>
<body>
<a href="#"> test </a>
</body>
[/HTML]
so you use a specific focus selector ... and i think this will not work with IE? ... with javascript you could call a function and use getElementById( ) and change the className.

kind regards
Mar 25 '08 #7
drhowarddrfine
7,435 Recognized Expert Expert
Yes, that will work, but like you said, only modern browsers and not IE.
Mar 25 '08 #8

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

Similar topics

4
2402
by: Scott Navarre | last post by:
Hi, I have Red Hat 8.0 and have the default Mozilla browser that comes with it. I am programming in javascript and have come across something problematic. Given the following code: <HTML> <HEAD> </HEAD> <BODY> <FORM>
1
8349
by: Cezary | last post by:
Hello. I have this code below and want to change background, but this works only in IE5.x. Why ? <div onmouseover="this.className='change'" onmouseout="this.className=''" style="width:100%;display:inline" class="txt11 nopad"> <div style="width:5%">....</div> <div style="width:43%">....</div>
2
3988
by: swathi | last post by:
----------------------------------------------------------------------- A poll associated with this post was created, to vote and see th results, please visit http://www.forum4designers.com/message103437.htm ----------------------------------------------------------------------- Question: iframe onfocus problem in mozilla browse - attached zip fil - multi.html in attached zi...
3
4775
by: michael | last post by:
I'm changing colors of table cells like this: <style type="text/css"> ..over {background-color: #bedddc} ..out {background-color: #99cccc} </style> <td onmouseover="this.className='over'" onmouseout="this.className='out'">
1
5822
by: r_mun | last post by:
Hello, I think it would be an interesting issue to everyone. What I'd like to do is simply change the style of my dynamically created table cell. I have written the following code to perform the actions: // sometimes you have to shake the container to make browser see // your style changes (shake = hide+show) vat tableState = table.style.display; // save display value of the table
3
10644
by: Robert | last post by:
Hi, Is it possible to dynamically change the style of a class instead of just an individual element? If so could you point me in the right direction? Robert
14
1570
by: Inny | last post by:
Im using This nifty code that works Great in IE but not so great in Mozilla, In ie if you add an image, the sidenote fits around it, but in mozilla the image just sits over the top. please help preveiw http://inny.ipbfree.com/index.php?showtopic=151&hl=,%20true veiw in both browsers to see the problem.
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
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
10113
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
9969
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...
1
7519
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
5402
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
5538
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
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.