Solved

javascript for onmouseover, onmouseout for a <A>

Posted on 2006-10-21
2
762 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
  • 2
2 Comments
 
LVL 41

Accepted Solution

by:
HonorGod earned 25 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

713 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