473,563 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

scrolling image on website

Hi,

I have this .jpg picture that's 700 x 200. What I wanna do is display
it on a 300 x 200 window, and have it scroll left and right, back and
forth.

Can anyone help this newbie? TIA
Jul 23 '05 #1
12 2713
Major Man wrote on 10 aug 2004 in comp.lang.javas cript:
I have this .jpg picture that's 700 x 200. What I wanna do is display
it on a 300 x 200 window, and have it scroll left and right, back and
forth.

Can anyone help this newbie? TIA


Google can:

http://www.google.com/search?q=scrol...age+javascript

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #2
On 10 Aug 2004 12:32:35 GMT, "Evertjan."
<ex************ **@interxnl.net > wrote:
Google can:

http://www.google.com/search?q=scrol...age+javascript


Okay I tried Google per above. None of those sites have what I'm
looking for, but this one comes very close:

http://www.qiksearch.com/javascripts...ling_image.htm

The only thing is, I don't want the image to scroll all the way to
the edge of the browser and then disappear.... I need the image
displayed in a 300x200 window, and scroll within that window ONLY.

Would it be possible to slightly alter the qiksearch.com code to do
this?
Jul 23 '05 #3
On Tue, 10 Aug 2004 22:43:03 +0200, Richard Hijdra
<in************ *@www.rhi.nl> wrote:
http://www.qiksearch.com/javascripts...ling_image.htm

Doesn't work in NS

R.


By NS do you mean Netscape?

That doesn't matter for me because everyone visiting my webpage will
be IE users.
Jul 23 '05 #5
>>>http://www.qiksearch.com/javascripts...ling_image.htm

Doesn't work in NS

R.

By NS do you mean Netscape?

That doesn't matter for me because everyone visiting my webpage will
be IE users.

Aha, OK! It was just to let u know...

Richard

Jul 23 '05 #6
Major Man <ma***@man.co m> writes:
On 10 Aug 2004 12:32:35 GMT, "Evertjan."
<ex************ **@interxnl.net > wrote:
Google can:

http://www.google.com/search?q=scrol...age+javascript
Okay I tried Google per above. None of those sites have what I'm
looking for, but this one comes very close:

http://www.qiksearch.com/javascripts...ling_image.htm


Ick. That's ... crappy code. Nestcape 4 and IE only, and uses
"eval" a lot. It's about as good an example as they get of
how *not* to do it :)
The only thing is, I don't want the image to scroll all the way to
the edge of the browser and then disappear.... I need the image
displayed in a 300x200 window, and scroll within that window ONLY. Would it be possible to slightly alter the qiksearch.com code to do
this?


I wouldn't bother (that would require *tocuhing* that code *yack*).

How about just doing:
---
<div style="width:32 0px;height:200p x;overflow:auto ;">
<img src="largeImage " style="width:70 0px;height:200p x;" alt="..">
</div>
---
(nothing beats scrollbars when you want people to scroll)

Or, if you want it to move automatically:
---
<div style="width:32 0px;height:200p x;overflow:hidd en;position:rel ative">
<img nam="foo" src="../../PicA.png"
style="width:70 0px;height:200p x;position:abso lute;" alt="..">
</div>
<script type="text/javascript">
var fooImg = document.images['foo'];
var fooCtr = 0;
function scrollFooDiv() {
fooCtr++;
var xpos = Math.round(-Math.cos(Math.P I*fooCtr/50)*190)+190;
fooImg.style.le ft = -xpos+"px";
}
setInterval(scr ollFooDiv, 100);
</script>
---
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #7
On Wed, 11 Aug 2004 00:25:18 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com > wrote:
How about just doing:
---
<div style="width:32 0px;height:200p x;overflow:auto ;">
<img src="largeImage " style="width:70 0px;height:200p x;" alt="..">
</div>
---
(nothing beats scrollbars when you want people to scroll)


I just tried this out. Manual scrollbar works surprisingly well, much
better than I thought it would.

Thanks dude, I'm gonna use this!
Jul 23 '05 #8
Lasse Reichstein Nielsen wrote on 11 aug 2004 in comp.lang.javas cript:
Or, if you want it to move automatically:
---
<div style="width:32 0px;height:200p x;overflow:hidd en;position:rel ative">
<img nam="foo" src="../../PicA.png"
style="width:70 0px;height:200p x;position:abso lute;" alt="..">
</div>
<script type="text/javascript">
var fooImg = document.images['foo'];
var fooCtr = 0;
function scrollFooDiv() {
fooCtr++;
var xpos = Math.round(-Math.cos(Math.P I*fooCtr/50)*190)+190;
fooImg.style.le ft = -xpos+"px";
}
setInterval(scr ollFooDiv, 100);
</script>


Nice.

By changing nam="foo" to name="foo" it works great.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 23 '05 #9
On Wed, 11 Aug 2004 00:25:18 +0200, Lasse Reichstein Nielsen
<lr*@hotpop.com > wrote:
Major Man <ma***@man.co m> writes:
On 10 Aug 2004 12:32:35 GMT, "Evertjan."
<ex************ **@interxnl.net > wrote:
Google can:

http://www.google.com/search?q=scrol...age+javascript


Okay I tried Google per above. None of those sites have what I'm
looking for, but this one comes very close:

http://www.qiksearch.com/javascripts...ling_image.htm


Ick. That's ... crappy code. Nestcape 4 and IE only, and uses
"eval" a lot. It's about as good an example as they get of
how *not* to do it :)
The only thing is, I don't want the image to scroll all the way to
the edge of the browser and then disappear.... I need the image
displayed in a 300x200 window, and scroll within that window ONLY.

Would it be possible to slightly alter the qiksearch.com code to do
this?


I wouldn't bother (that would require *tocuhing* that code *yack*).

How about just doing:
---
<div style="width:32 0px;height:200p x;overflow:auto ;">
<img src="largeImage " style="width:70 0px;height:200p x;" alt="..">
</div>
---
(nothing beats scrollbars when you want people to scroll)

Or, if you want it to move automatically:
---
<div style="width:32 0px;height:200p x;overflow:hidd en;position:rel ative">
<img nam="foo" src="../../PicA.png"
style="width:70 0px;height:200p x;position:abso lute;" alt="..">
</div>
<script type="text/javascript">
var fooImg = document.images['foo'];
var fooCtr = 0;
function scrollFooDiv() {
fooCtr++;
var xpos = Math.round(-Math.cos(Math.P I*fooCtr/50)*190)+190;
fooImg.style.le ft = -xpos+"px";
}
setInterval(scr ollFooDiv, 100);
</script>
---
/L


Nice code /L :) I'm currently working on the below if you care to
comment on it please, (as you've helped me out so much in the past)
maybe it might help the OP with some idea. this basically is to put 9
large maps into the "wrapper" and I will be adding wrap-around feature
to it. eg when the user scrolls onto any of the right 3 maps the far
left 3 are moved to the right letting the user scroll continuously
(sp) to the right.

(I tried below code and it works in IE6 & NS 7)
HTH the OP.

Al

THE CODE:
---------------------

<html>
<head>
<script type="text/javascript">

var iTimeoutTime = 10; // speed of scrolling inc to slowdown
var timeoutID = null; // ID to use to stop settimeout function
var movePixels = 10; // distance to move the maps on each scroll

window.document .onmouseout = stopScrollMap;
function scrollMap(sDire ction) {

var directionX = 0, directionY = 0;

switch(sDirecti on.toLowerCase( )) {
case 'up':
directionY = 1;
break;
case 'down':
directionY = -1;
break;
case 'left':
directionX = 1;
break;
case 'right':
directionX = -1;
break;
default:
break;
}

// Move all 9 maps in the direction
for(var i = 0; i < 9 ; i++) {
oHandle = document.getEle mentById('Map' + i);
if (oHandle) {

oHandle.style.l eft =
parseInt(oHandl e.style.left) + (movePixels * directionX) + 'px'
oHandle.style.t op =
parseInt(oHandl e.style.top) + (movePixels * directionY) + 'px'

}
}

// recall the function until the timeout ID is cleared.
timeoutID = setTimeout("scr ollMap('" + sDirection + "')",
iTimeoutTime);
}

function stopScrollMap() {
clearTimeout(ti meoutID);
}

</script>

<style type="text/css">
#FullMapWrapper {position: absolute; top:130; left: 130; width: 500px;
height:350px; overflow: hidden; background: transparent; border: thick
ridge }
#Map0 {position: absolute; top: -700px; left: -1000px;}
#Map1 {position: absolute; top: -700px; left: 0px;}
#Map2 {position: absolute; top: -700x; left: 1000px;}
#Map3 {position: absolute; top: 0px; left: -1000px;}
#Map4 {position: absolute; top: 0px; left: 0px;}
#Map5 {position: absolute; top: 0px; left: 1000px;}
#Map6 {position: absolute; top: 700px; left: -1000px;}
#Map7 {position: absolute; top: 700px; left: 0px;}
#Map8 {position: absolute; top: 700px; left: 1000px;}
</style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" >
<tr><td></td><td align="center"> <span
onmouseover="sc rollMap('up');" ><img
src="GreenUp.gi f"></span></td><td></td></tr>
<tr><td align="center"> <span onmouseover="sc rollMap('left') ;"><img
src="GreenLeft. gif"></span></td><td><img
src="Map-full_small.gif" ></td><td align="center"> <span
onmouseover="sc rollMap('right' );"><img
src="GreenRight .gif"></span></td></tr>
<tr><td></td><td align="center"> <span
onmouseover="sc rollMap('down') ;"><img
src="GreenDown. gif"></span></td><td></td></tr>
</table>

<div id="FullMapWrap per" >
<img id="Map0" src="map-0.gif" border="0" width="1000" height="700">
<img id="Map1" src="map-1.gif" border="0" width="1000" height="700">
<img id="Map2" src="map-2.gif" border="0" width="1000" height="700">
<img id="Map3" src="map-3.gif" border="0" width="1000" height="700">
<img id="Map4" src="map-4.gif" border="0" width="1000" height="700">
<img id="Map5" src="map-5.gif" border="0" width="1000" height="700">
<img id="Map6" src="map-6.gif" border="0" width="1000" height="700">
<img id="Map7" src="map-7.gif" border="0" width="1000" height="700">
<img id="Map8" src="map-8.gif" border="0" width="1000" height="700">
</div>

<script type="text/javascript">
for(var i = 0; i < 9 ; i++) {
oHandle = document.getEle mentById('Map' + i);
if (oHandle) {
oHandle.style.l eft = ((i % 3) * 1000)-1000 +
'px';
oHandle.style.t op = (Math.floor(i/3) *
700)-700 + 'px';
//alert('i='+i+' left='+oHandle. style.left + '
top=' + oHandle.style.t op);
}

}
</script>
</body>
</html>
Jul 23 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6511
by: delong | last post by:
Hi I am trying to display a large image on the form and make the form scrollable. My image is about 4200 x 7000 pixel. private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { Graphics g=e.Graphics;
1
2912
by: Vangelis Natsios | last post by:
I want to create a page with a scrolling image that will cause different messages to appear on another part of the page (say, another <div>) as the image will scroll. Imagine something like this: Image DIV Text DIV (Visible Area) +-----------+ Image +---------+...
0
3208
by: Paul Loveless | last post by:
Hi all. I have a user control that contains a picturebox within a panel with the panel set to autoscroll the picturebox. One thing that I have noticed with the default functionality is when you click and drag the scroll box (thumb track) the picturebox does not scroll until you release it. Is there a way to scroll the picturebox while you move...
2
3855
by: Sam | last post by:
Hope someone can help... I have an image on the page which i have made scrollable with the following code: <div id="Layer1" style="LEFT: 8px; TOP: 368px; height: 180px; width:780px; position: absolute; overflow-x: scroll"> <asp:image id="Image1" style="Z-INDEX: 105; LEFT: 8px; TOP: 368px" runat="server"...
7
4294
by: Yavuz Bogazci | last post by:
i have the following problem: my customer wants to show some informations in a WinForm. He has Images and Textelements with are connected. It should look like this: scroll << - ... Image + Text + empty space + Image + Text + empty space + Image + Text + empty space ... << - scroll to left how can i solve this problem? can i paste images...
3
3274
by: Aaron | last post by:
I'm trying to parse a table on a webpage to pull down some data I need. The page is based off of information entered into a form. when you submit the data from the form it displays a "Searching..." page then, refreshes and displays the table I want. I have code that grabs data from the page using cURL but when I look at the data it contains...
0
2696
by: ton | last post by:
Hi, I have an Image which is dark grey/black, at the top a white line, at the left site a white line as well. At 192 px from the left of the screen I position a DIV with this image as the background image. In the code I've added a multi line textbox (in my real world it is a treeview). It is placed that I would have to scroll to see the...
7
2738
by: jeddiki | last post by:
I want to check the size of an image file before I write it. If it is a certain size, then I won't write it. Can I check the future size of the file by using strlen() on the file_get_contents($url);? Here is my script: First I get the image from an image website,
0
7659
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7580
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7945
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3634
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3618
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2079
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1194
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.