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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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