Link to home
Start Free TrialLog in
Avatar of zvucini
zvuciniFlag for Croatia

asked on

javascript scrolling on click event

This is the code:

<img src="images/scrolldown.gif"  onClick="frames['iframe'].scrollBy(0,50)"  >

'iframe' is some name of iframe that i want to scroll when image is clicked.

What i need is to scroll iframe when mouse button is pressed and while is pressed it should scroll for 50 px, until mouse is released. When it's released it should stop scroll.

I tried some loop but it doesn't work.
Avatar of Sinoj Sebastian
Sinoj Sebastian
Flag of India image

This may Help you. You can get the concept from this small page. You have to use "onmousedown" event from img tag and "onmouseup" from body tag.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body{height:100%;}
body{background:#dee;}
div#divOne{margin:50px;height:300px;width:400px;background:#000;}
</style>
<script type="text/javascript">
function hi(){
document.getElementById('divTwo').innerHTML+="hi ";
}
</script>
</head>
<body onmouseup="if(window.sI)clearInterval(sI);">
<div id="divOne" onmousedown="sI=setInterval('hi()',10);">
</div>
<div id="divTwo">
</div>
</body>
</html>
Avatar of zvucini

ASKER

No, what i need is continuous scrolling od iframe until mouse is released. Now, it's scrolling only once.
ASKER CERTIFIED SOLUTION
Avatar of Sinoj Sebastian
Sinoj Sebastian
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zvucini

ASKER

Great!
 
Best regards,
Zoran
Avatar of zvucini

ASKER

Perfect!

Best regards