deadlyp99 Posted February 2, 2009 Share Posted February 2, 2009 so I'm not terribly new to js, been using it a few years. while trying to create some simple rollover buttons I am running into an error and after an hour of tinkering I cant find the problem. It's a simple answer, I know it has to be! It is bugging me. Help appreciated. <script type="text/javascript"> <![CDATA[ function over(id) { document.getElementById(id).style.backgroundColor="#487bb6"; document.getElementById(id).style.border="2px inset #3e72ad"; } ]]> </script> <!--// Main Links //--> <div id="links"> <div class="main_links" id="home" onmouseover="over('home');">Home</div> <div class="main_links" id="forum" onmouseover="over('forum');">Forum</div> <div class="main_links" id="register" onmouseover="over('register');">Sign Up</div> <div class="main_links" id="login" onmouseover="over('login');">Login</div> <div class="main_links" id="sigs" onmouseover="over('sigs');">Get a Sig</div> </div> <!--// End Main Links //--> Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/ Share on other sites More sharing options...
Zane Posted February 2, 2009 Share Posted February 2, 2009 What exactly is it NOT doing? and I'm going out on a long shot here but try capitalizing the m in onmouseover so you have onMouseover Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/#findComment-752615 Share on other sites More sharing options...
deadlyp99 Posted February 2, 2009 Author Share Posted February 2, 2009 Oh my bad, I didnt explain the problem -.- take a gander at: http://flgc.joshr.info/ I created a simple page and I have some css buttons. I plan to have the buttons "depress" and change to a darker color when the mouse is over. Once I figure out why that isnt working, I can get it to revert. As it stands I just get get "object expected" in IE on each link. OH! onmouseover="alert('lal')" works perfectly fine Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/#findComment-752625 Share on other sites More sharing options...
Zane Posted February 2, 2009 Share Posted February 2, 2009 Well, when I take the function out of CDATA ...AND I uncomment the core of the whole function.....for some reason it works <br /> function over(oeo) {//alert(oeo);<br /> document.getElementById(oeo).style.backgroundColor="#487bb6";<br /> document.getElementById(oeo).style.border="2px inset #3e72ad";<br /> }<br /> it was this <br /> <![CDATA[<br /> function over(oeo) {//alert(oeo);<br /> //document.getElementById(oeo).style.backgroundColor="#487bb6";<br /> //document.getElementById(oeo).style.border="2px inset #3e72ad";<br /> }<br /> ]]><br /> Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/#findComment-752634 Share on other sites More sharing options...
deadlyp99 Posted February 2, 2009 Author Share Posted February 2, 2009 Interesting... I used a html validator and it suggested putting that in for the javascript, so I did without even thinking about it. I've never run into problems before... Thanks. I knew it was a simple solution. And I knew the code was commented, I did that because errors were still being raised... guess it was the cdata -.- Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/#findComment-752641 Share on other sites More sharing options...
Zane Posted February 2, 2009 Share Posted February 2, 2009 yeah CDATA is mainly for XML http://en.wikipedia.org/wiki/CDATA Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/#findComment-752648 Share on other sites More sharing options...
deadlyp99 Posted February 2, 2009 Author Share Posted February 2, 2009 I validated it againsted xhtml 1.0 strict. Figures Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/143474-solved-onmouseover-ok-what-is-wrong-here/#findComment-752655 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.