473,467 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to display full resolution image at click of its thumbnail

17 New Member
I have made the html+javascript code.According to which when the page loaded the image size gets reduced to 50,50 and onclicking on it ,size increases to 500,500,but i done it with the one copy of image

But i want the click at thumnail of photos and display the full resolution of thumnail.


Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <body onload="changeIt();">
  4. <head>
  5.  
  6. <script langauge="javascript">
  7. var count=1;
  8. function changeIt()
  9. {
  10.  
  11. var width=50;
  12. var height=50;
  13. document.TheImage.width=width
  14. document.TheImage.height=height
  15.  
  16.  
  17. }
  18. function changeeIt()
  19.  
  20. {
  21. if(count==1)
  22. {
  23. var width=500
  24. var height=500
  25. document.TheImage.width=width
  26. document.TheImage.height=height
  27. count=2;
  28. }
  29. else if(count==2)
  30. {
  31. var amrit1=50
  32. var pal=50
  33. document.TheImage.width=amrit1
  34. document.TheImage.height=pal
  35. count=1;
  36.  
  37. }
  38.  
  39.  
  40. }
  41.  
  42.  
  43.  
  44. </script>
  45. </head>
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. <img src="/home/administrator/Desktop/aa" name="TheImage" onclick="changeeIt();">
  53.  
  54.  
  55.  
  56. <BR>
  57.  
  58.  
  59. </body>
  60. </html>

Please somebody help ,thanks in advance.
Oct 15 '10 #1
18 4732
acoder
16,027 Recognized Expert Moderator MVP
You should make a generic function which either takes the image name, ID or a reference to the image itself. Then replace "document.TheImage." with document.images[imageName]. to reference the correct image.
Oct 18 '10 #2
RamananKalirajan
608 Contributor
Hi,
Have a look over this link

Thanks and Regards
Ramanan Kalirajan
Oct 18 '10 #3
amritpalpathak
17 New Member
i have a html cum javascript code.There are 2 images one is thumnail and other is full resolution of the same.When somebody click the thumnail ,the full resl. would show and when click of full resl. the thumnail would show.It is going well but problem is that ,when click of thumnail ,it replaces a distance to other images that is looking very strange.
I want that after clicking on thumnail it shoult show the full res. without effecting the other images on the same page.Please take the look at "http://highslide.com/".I want something like that.

This is my html cum javascript code




Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script>
  4. window.onload = start;
  5. function start ()
  6. {
  7. allSmall ();
  8. allTriggers ();
  9. }
  10.  
  11. function allTriggers ()
  12. {
  13. var images = document.getElementsByTagName("img");
  14. for (var i = 0, image; image = images[i]; i++)
  15. image.onclick = othersSmallThisLarge;
  16. }
  17. function smallImage (image)
  18. {
  19. with (image.style) { width = 50; height = 50; }
  20. }
  21.  
  22. function largeImage (image)
  23. {
  24. with (image.style) { width = 500; height = 500; }
  25. }
  26.  
  27. function switchSize (image)
  28. {
  29.  
  30. if ( (image.offsetWidth != 500) && (image.offsetHeight != 500) )
  31. {
  32.  
  33. largeImage (image);
  34.  
  35. }
  36. else
  37. {
  38. smallImage (image);
  39. }
  40.  
  41. }
  42. function switchResolution (image)
  43. {
  44. var previous = image.src;
  45. image.src = image.getAttribute("data");
  46. image.setAttribute("data", previous);
  47. delete previous;
  48. }
  49. function allSmall ()
  50. {
  51. var images = document.getElementsByTagName("img");
  52. for (var i = 0, image; image = images[i]; i++)
  53. smallImage (image);
  54. }
  55. function othersSmallThisLarge ()
  56. {
  57. switchResolution (this);
  58. switchSize (this);
  59. }
  60. </script>
  61. </head>
  62. <body>
  63.  
  64. <img src="thumnail's path" data="full resl'path" />
  65. <img src="thumnail" data="full" />
  66. </body>
  67. </html>

You can also check this by running at your on system.

Thanks in advance
Nov 4 '10 #4
acoder
16,027 Recognized Expert Moderator MVP
If you want something like highslide, you'll need to move the image out of the flow of the page. Make the image position absolute (position:absolute in CSS) with top/left settings.
Nov 4 '10 #5
amritpalpathak
17 New Member
Thanks for reply.I am new to javascript and know not more abou CSS.Even i dont know where to put Css code.Please can you elaborate or add Css code into above code.


Hope you would reply
Nov 4 '10 #6
acoder
16,027 Recognized Expert Moderator MVP
You could set it with JavaScript too:
Expand|Select|Wrap|Line Numbers
  1. img.style.position = "absolute";
However, I think you'd probably be better served reading up on a tutorial to grasp the basics (see Offsite Links sticky for JavaScript links) first, or using a library/framework to make things easier for you.
Nov 4 '10 #7
amritpalpathak
17 New Member
As you said i add this tag at Line no 63.
<img.style.position = "absolute">
But it didnt effect.Again clicking on the images replaces a distance to others.
Nov 5 '10 #8
Dormilich
8,658 Recognized Expert Moderator Expert
that was not a tag, that was a JavaScript instruction.
Nov 5 '10 #9
amritpalpathak
17 New Member
Ok.but by adding that instrucion,it helped nothing .
Or that instruction is to be add elsewhere in the whole code?
Nov 5 '10 #10
Dormilich
8,658 Recognized Expert Moderator Expert
I guess that’s because your variable is called image, not img. I guess it belongs in one of the functions.
Nov 5 '10 #11
amritpalpathak
17 New Member
You mean javascript code should be as

<image.style.position = "absolute">

??
Nov 5 '10 #12
Dormilich
8,658 Recognized Expert Moderator Expert
nope. rather something like
Expand|Select|Wrap|Line Numbers
  1. function allTriggers ()
  2. {
  3. var images = document.getElementsByTagName("img");
  4. for (var i = 0, image; image = images[i]; i++) {
  5. image.onclick = othersSmallThisLarge;
  6. image.style.position = "absolute";
  7. }
  8. }
though I’m not sure, whether that is the right function to put it in.
Nov 5 '10 #13
acoder
16,027 Recognized Expert Moderator MVP
It'd be better in the large() function.

You'd also have to change it back when you want to make it small again. To avoid this, you could have a ready large image hidden initially which is shown when the thumbnail is clicked.
Nov 5 '10 #14
amritpalpathak
17 New Member
Dormilich,Your code is helpful but not at all.
Acoder,can you explain a bit how to do that
Nov 6 '10 #15
amritpalpathak
17 New Member
Expand|Select|Wrap|Line Numbers
  1.  function allTriggers ()
  2.  {
  3.  var images = document.getElementsByTagName("img");
  4.  for (var i = 0, image; image = images[i]; i++) {
  5.  image.onclick = othersSmallThisLarge;
  6.  image.style.position = "absolute";
  7.  }
  8.  }
This code fullfilled that i wants.but when we click on thumnail it show the full resolution picture of the same thumnail but it still show the other image's thumnail(near by of thumnail which you have clicked) under the full resol of the same


Any ideas?
Nov 6 '10 #16
amritpalpathak
17 New Member
i have a html cum javascript code.There is thumnail on the page .When somebody click the thumnail ,the full resolution of the same image would show and when click of full resolution the thumnail would show.It is going well with one thumanil of the page
when there are 2 thumanil on the same page,clicking on first thumnail shows the full resolution of the same but the 2nd thumnail is also showing at the back of full resolution.It looks like full resolution image is transparent..

Here is the code ,you can try it by running at your own computer.



Expand|Select|Wrap|Line Numbers
  1.  
  2.       <html>
  3.       <head>
  4.       <script>
  5.          window.onload = start;
  6.          function start () 
  7.        {
  8.          allSmall ();
  9.          allTriggers ();
  10.        }
  11.  
  12.        function allTriggers () 
  13.         {
  14.        var images = document.getElementsByTagName("img");
  15.        for (var i = 0, image; image = images[i]; i++)
  16. {
  17.        image.onclick = othersSmallThisLarge;
  18.        image.style.position = "absolute";
  19.         }
  20. }
  21.             function smallImage (image) 
  22.           {
  23.               with (image.style) { width = 50; height = 50; }
  24.           }
  25.  
  26.         function largeImage (image)
  27.            {
  28.         with (image.style) { width = 500; height = 500; }
  29.            }
  30.  
  31.            function switchSize (image) 
  32.         {
  33.  
  34.           if ( (image.offsetWidth != 500) && (image.offsetHeight != 500) ) 
  35.             {
  36.  
  37.           largeImage (image);
  38.  
  39.         } 
  40.           else 
  41.                   {
  42.                     smallImage (image);
  43.                   }
  44.  
  45.    }
  46.   function switchResolution (image)
  47.      {
  48.        var previous = image.src;
  49.        image.src = image.getAttribute("data");
  50.        image.setAttribute("data", previous);
  51.        delete previous;
  52.       }
  53.          function allSmall () 
  54.         {
  55.          var images = document.getElementsByTagName("img");
  56.          for (var i = 0, image; image = images[i]; i++)
  57.          smallImage (image);
  58.         }
  59.             function othersSmallThisLarge () 
  60.           {
  61.             switchResolution (this);
  62.             switchSize (this);
  63.           }
  64.               </script>
  65.               </head>
  66.               <body>
  67.                <images.style.position = "absolute"> 
  68.  
  69.      <img src="thumnail'path" data="full resolution image'path " />
  70.  
  71.      <img src="thumnail'path" data="full resolution image'path " />
  72.  
  73.  
  74.  
  75.            </body>
  76.            </html>
  77.  


Any suggestions ?

Thanx
Nov 14 '10 #17
amritpalpathak
17 New Member
There are 5 copies of the same images are placed in a folder i.e. large(1024*768),medium(500*375),small(240*180),thu mnail(75*75),square(100*50) in size....
The following code upload number of Geocoded images(square size) when the page loads.I want when someone click on the any Geocoded image on the page ,it should show the large image(1024*768) of the same.And further click on the large image it must show again the square size image of the same.
Following is a code of page


Expand|Select|Wrap|Line Numbers
  1. var epsg4326 = new OpenLayers.Projection("EPSG:4326");
  2. var OSVMain = (function() {
  3.     var map, markers, map_move_timeout;
  4.     var photos = {};
  5.     function mapChange() {
  6.         if( map_move_timeout )
  7.             clearTimeout(map_move_timeout);
  8.         map_move_timeout = setTimeout(mapChangeTimeout, 500);
  9.         updateLinks();
  10.     }
  11.     function updateLinks() {
  12.         var center = OSV.getMapCenter(map);
  13.         var zoom = map.getZoom();
  14.         $('#permalink').attr('href',OSV.getURLBase()+'?lat='+center.lat+'&lon='+center.lon+'&zoom='+zoom);
  15.         $('#kmllink').attr('href',getLocateLink('kml'));
  16.     }
  17.     function getLocateLink(format) {
  18.         var extent = OSV.getMapExtent(map);
  19.         var url = OSV.getURLBase()+'/api/photos/locate.'+format+'?bbox=';
  20.         url += [ extent.left, extent.bottom, extent.right, extent.top].join(',');
  21.         return url;
  22.     }
  23.     function mapChangeTimeout() {
  24.         map_move_timeout = null;
  25.         var url = getLocateLink('json');
  26.         $.get( url, null, photosLoaded, 'json' );
  27.     }
  28.     function photosLoaded(json) {
  29.         var new_photos = {};
  30.         var size = new OpenLayers.Size(50, 50);
  31.         var offset = new OpenLayers.Pixel(-25, -25);
  32.         for( var i = 0, l = json.length; i < l; ++i ) {
  33.             var p = new OSVPhoto(json[i]);
  34.             if( photos[p.data.id] ) {
  35.                 new_photos[p.data.id] = photos[p.data.id];
  36.                 photos[p.data.id] = null;
  37.             } else {
  38.                 var position = new OpenLayers.LonLat(p.data.lon,p.data.lat);
  39.                 var icon = new OpenLayers.Icon(p.url('square'), size, offset);
  40.                 p.marker  = new OpenLayers.Marker(position.clone().transform(epsg4326, map.getProjectionObject()), icon);
  41.                 new_photos[p.data.id] = p;
  42.                 markers.addMarker(p.marker);
  43.  
  44.             }
  45.         }
  46.         for( var k in photos ) {
  47.             var p = photos[k];
  48.             if( p && p.marker )
  49.                 markers.removeMarker(p.marker);
  50.         }
  51.         photos = new_photos;
  52.     }
  53.     function setup() {
  54.         var vectors;
  55.         var popup;
  56.  
  57.         map = new OpenLayers.Map($('#map').get(0), {
  58.             controls: [
  59.                 new OpenLayers.Control.ArgParser(),
  60.                 new OpenLayers.Control.Attribution(),
  61.                 new OpenLayers.Control.LayerSwitcher(),
  62.                 new OpenLayers.Control.Navigation(),
  63.                 new OpenLayers.Control.PanZoomBar()
  64.             ],
  65.             units: "m",
  66.             maxResolution: 156543.0339,
  67.             numZoomLevels: 20,
  68.             displayProjection: new OpenLayers.Projection("EPSG:4326")
  69.         });
  70.  
  71.         var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
  72.             displayOutsideMaxExtent: true,
  73.             wrapDateLine: true
  74.         });
  75.         map.addLayer(mapnik);
  76.  
  77.         var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
  78.             displayOutsideMaxExtent: true,
  79.             wrapDateLine: true
  80.         });
  81.         map.addLayer(osmarender);
  82.  
  83.         var numZoomLevels = Math.max(mapnik.numZoomLevels, osmarender.numZoomLevels);
  84.  
  85.         var start = OSV.getStartLocation();
  86.         var numzoom = map.getNumZoomLevels();
  87.         if (start.zoom >= numzoom) start.zoom = numzoom - 1;
  88.         map.setCenter(start.pos.clone().transform(epsg4326, map.getProjectionObject()), start.zoom);
  89.         OSV.setupMapEventHandlers(map);
  90.         map.events.register("moveend", map, mapChange);
  91.         map.events.register("zoomend", map, mapChange);
  92.         mapChange();
  93.  
  94.  
  95.  
  96.         markers = new OpenLayers.Layer.Markers("Markers", {
  97.             displayInLayerSwitcher: false,
  98.             numZoomLevels: numZoomLevels,
  99.             maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
  100.             maxResolution: 156543,
  101.             units: "m",
  102.             projection: "EPSG:900913"
  103.         });
  104.         map.addLayer(markers);
  105.  
  106.     }
  107.     return {
  108.         setup: setup,
  109.         1:1
  110.     };
  111. })();
  112. $(function(){
  113.     OSVMain.setup();
  114. });

Any suggestions ?
Thanking you
Nov 29 '10 #18
amritpalpathak
17 New Member
There are 5 copies of the same images are placed in a folder i.e. large(1024*768),medium(500*375),small(240*180),thu mnail(75*75),square(100*50) in size....
The following code upload number of Geocoded images(square size) when the page loads.I want when someone click on the any Geocoded image on the page ,it should show the large image(1024*768) of the same.And further click on the large image it must show again the square size image of the same.
Following is the actual code.It is in .js file
.


Expand|Select|Wrap|Line Numbers
  1. var epsg4326 = new OpenLayers.Projection("EPSG:4326");
  2. var OSVMain = (function() {
  3. var map, markers, map_move_timeout;
  4. var photos = {};
  5. function mapChange() {
  6. if( map_move_timeout )
  7. clearTimeout(map_move_timeout);
  8. map_move_timeout = setTimeout(mapChangeTimeout, 500);
  9. updateLinks();
  10. }
  11. function updateLinks() {
  12. var center = OSV.getMapCenter(map);
  13. var zoom = map.getZoom();
  14. $('#permalink').attr('href',OSV.getURLBase()+'?lat  ='+center.lat+'&lon='+center.lon+'&zoom='+zoom);
  15. $('#kmllink').attr('href',getLocateLink('kml'));
  16. }
  17. function getLocateLink(format) {
  18. var extent = OSV.getMapExtent(map);
  19. var url = OSV.getURLBase()+'/api/photos/locate.'+format+'?bbox=';
  20. url += [ extent.left, extent.bottom, extent.right,  extent.top].join(',');
  21. return url;
  22. }
  23. function mapChangeTimeout() {
  24. map_move_timeout = null;
  25. var url = getLocateLink('json');
  26. $.get( url, null, photosLoaded, 'json' );
  27. }
  28. function photosLoaded(json) {
  29. var new_photos = {};
  30. var size = new OpenLayers.Size(50, 50);
  31. var offset = new OpenLayers.Pixel(-25, -25);
  32. for( var i = 0, l = json.length; i < l; ++i ) {
  33. var p = new OSVPhoto(json[i]);
  34. if( photos[p.data.id] ) {
  35. new_photos[p.data.id] = photos[p.data.id];
  36. photos[p.data.id] = null;
  37. } else {
  38. var position = new OpenLayers.LonLat(p.data.lon,p.data.lat);
  39. var icon = new OpenLayers.Icon(p.url('square'), size, offset);
  40. p.marker = new OpenLayers.Marker(position.clone().transform(epsg4 326,  map.getProjectionObject()), icon);
  41. new_photos[p.data.id] = p;
  42. markers.addMarker(p.marker);
  43.  
  44. }
  45. }
  46. for( var k in photos ) {
  47. var p = photos[k];
  48. if( p && p.marker )
  49. markers.removeMarker(p.marker);
  50. }
  51. photos = new_photos;
  52. }
  53. function setup() {
  54. var vectors;
  55. var popup;
  56.  
  57. map = new OpenLayers.Map($('#map').get(0), {
  58. controls: [
  59. new OpenLayers.Control.ArgParser(),
  60. new OpenLayers.Control.Attribution(),
  61. new OpenLayers.Control.LayerSwitcher(),
  62. new OpenLayers.Control.Navigation(),
  63. new OpenLayers.Control.PanZoomBar()
  64. ],
  65. units: "m",
  66. maxResolution: 156543.0339,
  67. numZoomLevels: 20,
  68. displayProjection: new OpenLayers.Projection("EPSG:4326")
  69. });
  70.  
  71. var mapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
  72. displayOutsideMaxExtent: true,
  73. wrapDateLine: true
  74. });
  75. map.addLayer(mapnik);
  76.  
  77. var osmarender = new OpenLayers.Layer.OSM.Osmarender("Osmarender", {
  78. displayOutsideMaxExtent: true,
  79. wrapDateLine: true
  80. });
  81. map.addLayer(osmarender);
  82.  
  83. var numZoomLevels = Math.max(mapnik.numZoomLevels,  osmarender.numZoomLevels);
  84.  
  85. var start = OSV.getStartLocation();
  86. var numzoom = map.getNumZoomLevels();
  87. if (start.zoom >= numzoom) start.zoom = numzoom - 1;
  88. map.setCenter(start.pos.clone().transform(epsg4326 ,  map.getProjectionObject()), start.zoom);
  89. OSV.setupMapEventHandlers(map);
  90. map.events.register("moveend", map, mapChange);
  91. map.events.register("zoomend", map, mapChange);
  92. mapChange();
  93.  
  94.  
  95.  
  96. markers = new OpenLayers.Layer.Markers("Markers", {
  97. displayInLayerSwitcher: false,
  98. numZoomLevels: numZoomLevels,
  99. maxExtent: new OpenLayers.Bounds(-20037508,-20037508,20037508,20037508),
  100. maxResolution: 156543,
  101. units: "m",
  102. projection: "EPSG:900913"
  103. });
  104. map.addLayer(markers);
  105. Any suggestions ?
  106. Thanking you
  107. }
  108. return {
  109. setup: setup,
  110. 1:1
  111. };
  112. })();
  113. $(function(){
  114. OSVMain.setup();
  115. });

Any suggestions ?
Thanking you
Dec 5 '10 #19

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

Similar topics

9
by: Deepa | last post by:
Hi All, I'm facing problem displaying image of size 5000X5000 .My window size is smaller than image size so i'm not able to see the complete image.i can use scroll bars to view the image but i...
2
by: Ben Amada | last post by:
Hi group. I'm going to display a low resolution image in an HTML page. On the web server, I have a high resolution version of that image. If I display the high resolution image in the browser...
3
by: Varangian | last post by:
How can I make a Image Click working before Page Load event? The Problem I'm getting is that I'm loading an ImageButton dynamically from a Web User Control. How can I make the Web User Control...
1
by: Brett Wesoloski | last post by:
I am having problems getting the index of an image click event in a datagrid. Every time I look at the index it is -1. What I am trying to do is get the index of the row in which the imagebutton...
2
by: Ahmd | last post by:
Pls look at this code, i want to call this function from an image click event. CPage=Cint(Request.Form("CurrentPage")) 'get CPage value from form's CurrentPage field Select Case...
3
by: nagamalli26 | last post by:
hi iam new php i want php code for display full resume please send my mail_id
2
by: ranjeshh | last post by:
How do I display a jpeg image using c..Please gude me as I m new to image processing..I would appreciate if someone could give me a working code with explanation
4
by: ameshkin | last post by:
I have a checkbox with an ID of svc_tp_1, and an image that corresponds with this checkbox below it. <input type="checkbox" name="checkbox" id="svc_tp_1" value="svc_tp_1" / <img...
6
by: msmjsuarez | last post by:
how can i display both image and other information in the web page using php? i'm using mysql database. I do displaying the image only but i want to display both other information from the database...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.