User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 397,801 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,428 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2039 | Replies: 3
Reply
Join Date: Jun 2006
Location: UK (Bristol)
Posts: 225
Reputation: Mushy-pea is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
Mushy-pea's Avatar
Mushy-pea Mushy-pea is offline Offline
Posting Whiz in Training

Javascript + HTML DOM problem

  #1  
Oct 2nd, 2006
Hello everyone. I am trying to write a drop down menu Javascript and have run into a little problem. I need to change the (opacity=0) value inside this custom style:

<style id="menu_style" type="text/css"><!--.menu {z-index: 3; filter: alpha(opacity=0); position: absolute; left: 200px; top: 100px; width: 180px; height: 210px; background-color: #0000FF}

The obvious approach would seem to be:

document.getElementById("menu_style").menu="....

and fill out the contents of the .menu attribute with the changed opacity value. However, when I try this nothing gets changed and my menu remains invisible :mad: . I have read some tutorials on w3schools about this but they don't go into the specifics of changing custom styles with DOM. Any help with this little snag would be appriciated.

Steven.
Hello, you're through to Steven on the BT Business technical help desk. Could I take your broadband telephone number please?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Javascript + HTML DOM problem

  #2  
Oct 3rd, 2006
I believe "CSS" filters are an IE-only, non-standard, non-compliant "thing".

Regardless, you cannot change the CSS declaration itself. CSS Stylesheets are not part of the DOM. You can, however, use JavaScript to change the style of an individual HTML element. Since styles cascade, the element will use the original class/id declaration except when specifically overriden by an inline style.

So, rather than trying to get the "CSS element", get a handle to the actual styled HTML element, and interact with it.
Last edited by tgreer : Oct 3rd, 2006 at 9:25 am.
Reply With Quote  
Join Date: Jun 2005
Location: Denmark, EU
Posts: 102
Reputation: madmital is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
madmital madmital is offline Offline
Junior Poster

Re: Javascript + HTML DOM problem

  #3  
Oct 3rd, 2006
CSS "filters" are IE-only.

Use the "visibility" att.

Something along the lines of this should work:
<style>
#dropdownmenu { position: absolute; top: 20px; left: 20px; visibility : hidden; }
</style>
<javascript>
   function showDropDown()
  {
    document.getElementById("dropdownmenu").style.visibility = "visible";
  }
</javascript>

<a onMouseOver="showDropDown()">show me now</a>

<div id="dropdownmenu">
item
item
item
</div>
Web Programmer
Reply With Quote  
Join Date: Jun 2006
Location: UK (Bristol)
Posts: 225
Reputation: Mushy-pea is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
Mushy-pea's Avatar
Mushy-pea Mushy-pea is offline Offline
Posting Whiz in Training

Re: Javascript + HTML DOM problem

  #4  
Oct 4th, 2006
Thanks for the help. Now it works! It's a good job somone mentioned that "filter: alpha" is IE only or I'd have left a somewhat large glitch on my site.

Steven.
Hello, you're through to Steven on the BT Business technical help desk. Could I take your broadband telephone number please?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 6:05 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC