Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

javascript for onmouseover, onmouseout for a <A>

Posted on 2006-10-21
2
Medium Priority
?
785 Views
Last Modified: 2012-05-05
Hi!

Here's the code I have:

-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script language="javascript" type="text/javascript">  
    function HyperlinkStyle1OnMouseOver(obj, strobj)
    {
        var clr = "#cc9900";
        var td = "none";
        var bc = "#F0F0F0";
        var str = "<a id=\"" + strobj + "\" style='background-color:" + bc + "; color:" + clr + "; text-decoration:" + td + ";' onmouseover=\"javascript:HyperlinkStyle1OnMouseOver(" + strobj + ",'" + strobj + "');\" onmouseout=\"javascript:HyperlinkStyle1OnMouseOut(" + strobj + ",'" + strobj + "');\" href='Default.aspx'>Admin</a>";
        obj.outerHTML = str;
    }
    function HyperlinkStyle1OnMouseOut(obj, strobj)
    {
        var clr = "#608888";
        var td = "underline";
        var bc = "white";
        var str = "<a id=\"" + strobj + "\" style='background-color:" + bc + "; color:" + clr + "; text-decoration:" + td + ";' onmouseover=\"javascript:HyperlinkStyle1OnMouseOver(" + strobj + ",'" + strobj + "');\" onmouseout=\"javascript:HyperlinkStyle1OnMouseOut(" + strobj + ",'" + strobj + "');\" href='Default.aspx'>Admin</a>";
        obj.outerHTML = str;
        alert(obj.outerHTML);
    }    
    </script>
</head>
<body>
<a id='span6' style="color: #608888" onmouseover="javascript:HyperlinkStyle1OnMouseOver(span6,'span6');" onmouseout="javascript:HyperlinkStyle1OnMouseOut(span6,'span6');" href="Default.aspx">Admin</a></p>
</body>
</html>
-->

When the mouse is over the hyperlink, the style changes. However, when the mouse moves out, the style doesnt revert back. the Alert() in the OnMouseOut() code never gets called. Can someone help me in figuring out what I'm doing wrong?

Thanks,
Mustansir
0
Comment
Question by:muskad202
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 100 total points
ID: 17780126
 You've made it too hard.  Try something easier, like:
----------------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.normal {
    color            : #608888;
      background-color : white;
    text-decoration  : none;
}
.special {
    color            : #F0F0F0;
      background-color : white;
    text-decoration  : underline;
}
</style>

<script type="text/javascript">  
    function Over( obj )
    {
      obj.className = 'special';
    }
    function Out( obj )
    {
      obj.className = 'normal';
      alert( 'out()' );
    }    
    </script>
</head>
<body>
<a id='span6' class='normal' onmouseover='Over(this);' onmouseout='Out(this);' href='Default.aspx'>Admin</a>
</body>
</html>
0
 
LVL 41

Expert Comment

by:HonorGod
ID: 17781618
Thanks for the 'A'
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question