Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onmouseover equivalent

Status
Not open for further replies.

grnzbra

Programmer
Mar 12, 2002
1,273
US
HTML has an event attribute onmouseover which I can use to launch a script. Is there any equivalent in VBScript which would allow me to check if the mouse is over an element? Kinda like

If mouseover
Do something cool
End If
 
>Is there any equivalent in VBScript which would allow me to check if the mouse is over an element?
If you mean in the realm of html, sure, why do you doubt that? as long as the agent support vbscript, such as ie. If you mean something else, then I cannot answer.
[tt]
<html>
<head>
<script language="vbscript">
sub x
dim onode
set onode=window.event.srcElement
msgbox onode.id & vbcrlf & onode.tagName & vbcrlf & onode.innerHTML
set onode=nothing
end sub
</script>
</head>
<body>
<div id="divid" style="width:30%;background-Color:yellow;" onmouseover="x">mouse over event scripted</div>
</body>
</html>
[/tt]
 
Thank you. It was a great help and works quite nicely in some instances. However I am trying to highlight a row in a table which is a tabular data control. I can get it to work correctly if the value in the field is unique to that row. However, if there are any other rows with the same value in that field, those will be highlighted also. Is there any way to make this see the innertext value for each field in a row?
 
>I can get it to work correctly if the value in the field is unique to that row. However, if there are any other rows with the same value in that field, those will be highlighted also.
You get that to work but cannot get an apparently simpler handling to work? And you prefer description than showing your script? Can the forum assume your description is correct, and how? Is that your script? or somebody else's?
[tt]
<html>
<head>
<style type="text/css">
table {cursor:hand;}
</style>
<script language="vbscript">
sub x
dim otbl,orow
set otbl=document.getElementsByTagName("table")(0)
for each orow in otbl.rows
orow.attachEvent "onmouseover",getref("movr_handle")
orow.attachEvent "onmouseout",getref("mout_handle")
next
set otbl=nothing
end sub
sub movr_handle
window.event.srcElement.parentNode.style.backgroundColor="yellow"
end sub
sub mout_handle
window.event.srcElement.parentNode.style.backgroundColor="white"
end sub
set window.onload=getRef("x")
</script>
</head>
<body>
<table border="1">
<tbody>
<tr>
<td>123</td><td>234</td><td>345</td>
</tr>
<tr style="background-color:red;">
<td>543</td><td>432</td><td>321</td>
</tr>
<tr>
<td>234</td><td>345</td><td>456</td>
</tr>
</tbody>
</table>
</body>
</html>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top