HighTechTalks DotNet Forums  

Javascript OnMouseOver Event not executing function inside it...

Dotnet Scripting microsoft.public.dotnet.scripting


Discuss Javascript OnMouseOver Event not executing function inside it... in the Dotnet Scripting forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
den 2005
 
Posts: n/a

Default Javascript OnMouseOver Event not executing function inside it... - 07-11-2006 , 08:48 PM






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
--
MCP Year 2005, Philippines

Reply With Quote
  #2  
Old   
Peter Torr \(MS\)
 
Posts: n/a

Default Re: Javascript OnMouseOver Event not executing function inside it... - 07-12-2006 , 11:04 AM






"den 2005" <den2005 (AT) discussions (DOT) microsoft.com> wrote

Quote:
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

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




Reply With Quote
  #3  
Old   
den 2005
 
Posts: n/a

Default Re: Javascript OnMouseOver Event not executing function inside it. - 07-12-2006 , 10:10 PM



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


--
MCP Year 2005, Philippines


"Peter Torr (MS)" wrote:

Quote:
"den 2005" <den2005 (AT) discussions (DOT) microsoft.com> wrote in message
news:3ED9AFAF-EFF9-4496-9C4A-C5D449F7FEE7 (AT) microsoft (DOT) com...
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

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




Reply With Quote
  #4  
Old   
den 2005
 
Posts: n/a

Default Re: Javascript OnMouseOver Event not executing function inside it. - 07-13-2006 , 04:44 AM



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


--
MCP Year 2005, Philippines


"den 2005" wrote:

Quote:
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


--
MCP Year 2005, Philippines


"Peter Torr (MS)" wrote:

"den 2005" <den2005 (AT) discussions (DOT) microsoft.com> wrote in message
news:3ED9AFAF-EFF9-4496-9C4A-C5D449F7FEE7 (AT) microsoft (DOT) com...
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

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




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.