Jump to content

[SOLVED] onmouseover.... ok what is wrong here?


deadlyp99

Recommended Posts

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 //-->

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

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 />

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 -.-

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.