[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

javascript scrolling on click event

Posted on 2007-11-25
5
Medium Priority
?
3,084 Views
Last Modified: 2010-04-21
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.
0
Comment
Question by:zvucini
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 20346727
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>
0
 
LVL 2

Author Comment

by:zvucini
ID: 20346779
No, what i need is continuous scrolling od iframe until mouse is released. Now, it's scrolling only once.
0
 
LVL 12

Accepted Solution

by:
Sinoj Sebastian earned 2000 total points
ID: 20346973
Iframe scrolling example


<!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;}
</style>
<script type="text/javascript">

function scroll_iframe() {
  if (window.frames["iframe"]) {
    window.frames["iframe"].scrollBy(0, 5);
  }
}

</script>
</head>
<body onmouseup="if(window.sI)clearInterval(sI);">
<img src="http://www.roomforboxing.com/images/down-arrow.gif"  onmousedown="sI=setInterval('scroll_iframe()',10);"/>

<iframe name="iframe" id="iframe" src="page_two.html" width="100%" height="200" frameborder="0">Sorry, your browser doesn't support iframes.</iframe>
</body>
</html>
0
 
LVL 2

Author Closing Comment

by:zvucini
ID: 31410880
Great!
 
Best regards,
Zoran
0
 
LVL 2

Author Comment

by:zvucini
ID: 20347042
Perfect!

Best regards
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question