Hi
I wanted to put a DIV in a page, then every time the user moves mouse over it, I wanted it to clip downward. (To have something like an scroll efect).
I tried this first:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script>
function show(x){
setInterval("scroll("+x+")",100)
}
function scroll(n){
window.status+=n
}
</script>
<body>
<div onMouseOver="show(this)">Salaaaaaaaaaam</div>
</body>
</html>
In this model, show function would be used for setting the visibility of DIV. (I need this, because I want to set the visibility of some other DIVs at the same time).
The variable sent to it is the DIV object, obviously. Now the scroll function (which must be later coded to clip the DIV object), contains only a test code. If it is run correctly, it must fill the status bar with [object] s.
It failed! It said, "object is undifined"
I changed the show(x) function to such:
function show(x){
setInterval("scroll(x)",100)
}
It gave me the same error message.
I thought this is because I am trying to send the X variable to a function outside the show(x) function, and thus, X is undifined to the scroll(n) function. So:
function show(x){
window.status+=x.toString()
setInterval("show("+x+")",100)
}
It again failed! This time one [object] was shown in the status bar (because windo.status command was run once, when it was called by the mousover event.) But it failed to repeat.
I have always used setInterval and setTimeout for functions that do not need arguments,ie setInterval("func()",time), and not for those which need arguments, ie setInterval("func(arg)",time). But I need this now.
Any ideas?
A simple code that can result in a drop down effect is excellent!
Huji
To avoid that string problem you have to create a global var and assign to it the reference.
Like this:
<div onMouseOver="theDiv=this;s