473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

enlarge image on mouseover

I have a column in a gridview that fills with images from the gridview. I am very new to javascript so I googled until I found a good javascript function that enlarges this image onmouseover.
Expand|Select|Wrap|Line Numbers
  1. function Large(obj)
  2.     {
  3.  
  4.      var imgbox=document.getElementById("imgbox");
  5.      imgbox.style.visibility='visible';
  6.      var img = document.createElement("img");
  7.      img.src=obj.src;
  8.      img.style.height="180px";
  9.      imgbox.innerHTML='';
  10.      imgbox.appendChild(img);
  11.     } 
  12.  
  13.     function Out(obj)
  14.     {
  15.         document.getElementById("imgbox").style.visibility='hidden';
  16.     }
  17.     function Move(obj,e)
  18.     {
  19.         var mouseY=e.clientY;
  20.        // alert(e.x)
  21.      var mouseX=e.clientX;
  22.      var scrollTop=document.documentElement.scrollTop;
  23.      var scrollLeft=document.documentElement.scrollLeft;
  24.      var y=scrollTop+mouseY+20;
  25.      var x=scrollLeft+mouseX+20;
  26.      document.getElementById("imgbox").style.left=x + "px";
  27.      document.getElementById("imgbox").style.top=y + "px";
  28.     }
  29.     function Change(obj, evt)
  30.         {
  31.             if(evt.type=="focus")
  32.                 obj.style.borderColor="red";
  33.             else if(evt.type=="blur")
  34.                obj.style.borderColor="green";
  35.     } 
it works great. my only problem is that this is not exactly what I want to do. I want a small image of a camera to be in the column. when they put their mouse over the image of the camera, the image that really belongs in that column should popup in the div. thanx so much.
Jul 19 '10 #1
4 6221
@readbanana
You need to explain what applicatin is it? What platform it is Web or Winforms??
Jul 26 '10 #2
this is for the web
Jul 26 '10 #3
Bassem
344 100+
Hello,

I suggest you can use JQuery instead of pure JavaScript. Just because JQuery is simpler and you will accomplish both sub-tasks(on mouse hover, resize image) in very short lines.

This is a very useful like.

Thanks,
Bassem
Jul 27 '10 #4
I figured it out in case anyone else needs it, here's my code.
Expand|Select|Wrap|Line Numbers
  1. function Large(image)
  2.     {
  3.     var bigpic =image.nextElementSibling;
  4.     bigpic.style.visibility = 'visible';
  5. function Out(image)
  6.     {
  7.     var bigpic =image.nextElementSibling;
  8.     bigpic.style.visibility = 'hidden';
  9. function Move(image,e)
  10.     {
  11.      var mouseY=e.clientY;
  12.      var mouseX=e.clientX;
  13.      var scrollTop=document.documentElement.scrollTop;
  14.      var scrollLeft=document.documentElement.scrollLeft;
  15.      var y=scrollTop+mouseY+20;
  16.      var x=scrollLeft+mouseX+20;
  17.      var bigpic =image.nextElementSibling;
  18.      bigpic.style.left=x + "px";
  19.      bigpic.style.top=y + "px";
Jul 27 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John | last post by:
Imagine this: I have a gif-image with text, coloured green. When MouseOver occurs the gif will swap to another gif with red colourded text. On MouseOut the gif turns back to the green text. ...
8
by: PhilM | last post by:
Having googled myself silly, I now ask, if only to confirm my conclusions Is it possible to emulate the <javascript>mouseover in css, to replace link images with an alternate? Having asked, I...
2
by: Progman | last post by:
tell me how do you change an image from another when the mouse is over using asp.net please past some code
0
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I am building a web site with theme support, under each theme's folder there are some images. Some of my images need to be skinned, I know I can build a skin file with line like ...
4
by: ericjiii | last post by:
Hi. A friend of mine asked me if I could look at one of his java scripts in order to get it working. Unfortunately I am stumped and was wondeirng if somebody with a bit more experience than myself...
0
by: numbnutz | last post by:
Hi, I am currently working on an XML Gallery for my girlfriend's brother who is a photographer. I have created a flash front end template and am using an XML database to load the images and...
2
by: hobo38 | last post by:
Hi, I have tried to incorporate an image increase and decrease on mouseover from an earlier posting. Can anyone help me do this with multiple images? Here is the html page I have as a sample: ...
4
by: sourapple77 | last post by:
hi, I'm using flash button like "zoom in" to enlarge an image from html using javaScript. How can I do this? ex. I have flash media inserted within html document and once the button inside...
1
by: lisles | last post by:
hi; Im using a gridview to display images in 1 of the column...but the size of the images is very small.is there anyway to enlarge the image on mouseover or even without mouseover by adjusting the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.