Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Scripting / July 2006

Tip: Looking for answers? Try searching our database.

Javascript OnMouseOver Event not executing function inside it...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
den 2005 - 12 Jul 2006 01:48 GMT
Hi everybody,

  I am confused and still looking why this codes is not working. Can anyone
notice or know why this code is not working? Thanks in advanced.

The error is inside <img> tag:
 onmouseover="mouseOverImage()"
system says "Micrsoft JScript Runtime Error: Object Expected

When I change cursor type directly inside onmouseover event of Img tag,
there is no problem.

 onmouseover="this.style.cursor='w-resize'"

Code Not working:

<script type="text/javascript" language="javascript">        
    ...        
        function mouseOverImage()
        {
           document.getElementById('Img3').style.cursor = "w-resize";
        }
       ...
</script>

<form id="form1" runat="server">
   <div>
        </div>
   <div>
       <asp:Panel ID="Panel1" runat="server" Height="120px" Width="700px">  
         
           <input id="Text1" type="text" onmouseover="mouseHover('Text1')"
/><br />
           <textarea id="TextArea1" cols="20" rows="2"
onmouseover="mouseHover('TextArea1')"></textarea><br />
           <img src="images/rock.jpg" id="Img3"
onmouseover="mouseOverImage()" /><br /><br />  <<--- not working ok
           <input id="Button3" type="button" value="button" /><br />        
   
       </asp:Panel>  
       ....  
</form>

or

<script type="text/javascript" language="javascript">        
    ...        
        function mouseOverImage(obj)
        {
           obj.style.cursor = "w-resize";
        }
       ...
</script>

<form id="form1" runat="server">
   <div>
        </div>
   <div>
       <asp:Panel ID="Panel1" runat="server" Height="120px" Width="700px">  
         
           <input id="Text1" type="text" onmouseover="mouseHover('Text1')"
/><br />
           <textarea id="TextArea1" cols="20" rows="2"
onmouseover="mouseHover('TextArea1')"></textarea><br />
           <img src="images/rock.jpg" id="Img3"
onmouseover="mouseOverImage(this)" /><br /><br />  <<--- not working ok
           <input id="Button3" type="button" value="button" /><br />        
   
       </asp:Panel>  
       ....  
</form>

or

<script type="text/javascript" language="javascript">        
    ...        
        function mouseOverImage(var obj)
        {
           obj.style.cursor = "w-resize";
        }
       ...
</script>

<form id="form1" runat="server">
   <div>
        </div>
   <div>
       <asp:Panel ID="Panel1" runat="server" Height="120px" Width="700px">  
         
           <input id="Text1" type="text" onmouseover="mouseHover('Text1')"
/><br />
           <textarea id="TextArea1" cols="20" rows="2"
onmouseover="mouseHover('TextArea1')"></textarea><br />
           <img src="images/rock.jpg" id="Img3"
onmouseover="mouseOverImage(this)" /><br /><br />  <<--- not working ok
           <input id="Button3" type="button" value="button" /><br />        
   
       </asp:Panel>  
       ....  
</form>

or

<script type="text/javascript" language="javascript">        
    ...        
        function mouseOverImage()
        {
           document.body.style.cursor = "w-resize";
        }
       ...
</script>

<form id="form1" runat="server">
   <div>
        </div>
   <div>
       <asp:Panel ID="Panel1" runat="server" Height="120px" Width="700px">  
         
           <input id="Text1" type="text" onmouseover="mouseHover('Text1')"
/><br />
           <textarea id="TextArea1" cols="20" rows="2"
onmouseover="mouseHover('TextArea1')"></textarea><br />
           <img src="images/rock.jpg" id="Img3"
onmouseover="mouseOverImage()" /><br /><br />  <<--- not working ok
           <input id="Button3" type="button" value="button" /><br />        
   
       </asp:Panel>  
       ....  
</form>

den2005
Signature

MCP Year 2005, Philippines

Peter Torr (MS) - 12 Jul 2006 16:04 GMT
>   I am confused and still looking why this codes is not working. Can
> anyone
> notice or know why this code is not working? Thanks in advanced.

Do you have more than one element with the id "Img3"? If so, you will get
back a collection of elements.

Also you don't need to find the element again anyway -- you already know
which one it was (it fired the event). Try this instead:

   function onMouseOver(obj)
   {
     obj.style.cursor = 'foo'
   }

   <img onmouseover="onMouseOver(this)">

Peter

Signature

Peter Torr - http://blogs.msdn.com/ptorr
HD DVD Program Manager

den 2005 - 13 Jul 2006 03:10 GMT
Thanks Peter for info...

Any ideas to simulate a dragging effect while resizing the image control?
I am able to resize the control already but unable to still display the
dragging effect of resizing.

Dennis

Signature

MCP Year 2005, Philippines

> >   I am confused and still looking why this codes is not working. Can
> > anyone
[quoted text clipped - 14 lines]
>
> Peter
den 2005 - 13 Jul 2006 09:44 GMT
Problem with dragging effect of resizing is working but having problem with
setting a flag to determine if mouse button is click or not. Is there anyone
knows how to fixed this? I used several ways to do this as shown below, all
telling me the error below. I used IE 6 w/ SP1.

Error message:

Microsoft JScript runtime error: Object doesn't support this property or
method

Approaches used:

1. I even used 'false' & 'true' and 0 & 1.

var mousedown = false;

inside mousedown,

mousedown = true;

inside mousemove,

if (mousedown)

{

....

}

2.

if (window.event.button == 1)

den2005

Signature

MCP Year 2005, Philippines

> Thanks Peter for info...
>
[quoted text clipped - 22 lines]
> >
> > Peter

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.