Web Analytics Made Easy -
StatCounter Add mouseover and mouseout event to document.write - CodingForum

Announcement

Collapse
No announcement yet.

Add mouseover and mouseout event to document.write

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add mouseover and mouseout event to document.write

    Hi everyone

    I have a problem. I am trying to add mouseout and mouseover event to flash object using document.write so that I can show or hide text when someone rollover on flash but I am not sure how to do that? Please check my code and make any necessary changes to it. Please help me.

    Thanks

    Code:
    <script language="JavaScript" type="text/javascript">
    function CngTxt(id,txt){
    var obj=document.getElementById(id);
    if (txt){ obj.innerHTML=txt; }
    else { obj.innerHTML=''; }
    }
    </script>
    Code:
    document.write("onMouseOver=\"CngTxt('Txt','Topic&nbsp;2');\"");
    document.write("onMouseOut=\"CngTxt('Txt');\"");
    Code:
    <div id="Txt" class="menutextbox"></div>

  • #2
    I'm not sure where in your code you have the document.write, but if it's not running as the page is loading it's going to cause issues. And since you would need to have that script running inside the div tag's open/close it would be improper syntax anyway.

    Why not just do this:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Test</title>
    <link rel="stylesheet" type="text/css" href="css/" />
    <style type="text/css">
    .menutextbox
    {
    width: 200px;
    height: 160px;
    background-color: #ff0000;
    }
    </style>
    <script type="text/javascript">
    // <![CDATA[
    
    [COLOR="Red"]function CngTxt(eid,txt)
    	{
    	var obj = document.getElementById(eid);
    	obj.innerHTML = txt || "";
    	}[/COLOR]
    
    // ]]>
    </script>
    </head>
    <body>
    
    [COLOR="Red"]<div id="Txt" class="menutextbox" onmouseover="CngTxt('Txt','Topic 2')" onmouseout="CngTxt('Txt')"></div>[/COLOR]
    
    </body>
    </html>
    Feel free to e-mail me if I forget to respond ;)
    [email protected]

    Comment


    • #3
      Thanks mate. Really appreciate.

      Comment

      Working...
      X