473,799 Members | 2,907 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

enlarge image on mouseover

37 New Member
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 6250
fastestindian
74 New Member
@readbanana
You need to explain what applicatin is it? What platform it is Web or Winforms??
Jul 26 '10 #2
readbanana
37 New Member
this is for the web
Jul 26 '10 #3
Bassem
344 Contributor
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
readbanana
37 New Member
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
13457
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. -----------------This is my code: <a href="nextpage.html" onMouseOver="document.green.src='red.gif'" onMouseOut="document.green.src='green.gif'">
8
38797
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 now return to google, in case I missed heaps. ;) Regards, PhilM
2
1339
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
1773
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 <asp:Image runat="server" ImageUrl="images/email.gif" skinid="Email" BorderWidth="0" /> Then in my master page or web page I can call this skin like
4
1783
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 can look it over and help me identify what is wrong . <script LANGUAGE="JavaScript"> <!-- Begin image10 = new Image(); var imageDir = "http://2005.rock103.com/pages/bod/thong/"; var d = new Date()
0
4201
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 accompanying captions. The gallery has more than one image and the user can navigate the gallery by clicking forward and backward buttons to take then through the images: var galleryXML = new XML(); galleryXML.ignoreWhite = true;...
2
4133
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: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
4
3543
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 the flash is pressed viewers can view the enlarged image from their page. thank you in advance.
1
4663
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 column width or something.i would prefer doing it by mouseover.can anybody help me...my code is below <%@ Page Language="C#" AutoEventWireup="true" CodeFile="news_evnts.aspx.cs" Inherits="news_evnts" %> <!DOCTYPE html PUBLIC "-//W3C//DTD...
0
9685
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9538
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9068
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7563
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6804
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5461
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3755
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.