473,322 Members | 1,473 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,322 software developers and data experts.

Map image works in IE but not Firefox

This is what should happen in Firefox - this is in IE: http://www.sacu.com/locations/locate.asp

This is the javascript that manupulates the images. It is slightly modified from the IE version. I can get the map images to display, but can not get them positioned properly nor can I move the black rectangle.

Here is the code:

Expand|Select|Wrap|Line Numbers
  1. // CREDITS:
  2. // MapBlaster by Urs Dudli and Peter Gehrig 
  3. // Copyright (c) 2001 Peter Gehrig and Urs Dudli. All rights reserved.
  4. // Permission given to use the script provided that this notice remains as is.
  5. // Additional scripts can be found at:
  6. // http://www.designerwiz.com/24fun/uti...apzoomer2.html
  7. // 03/07/2001
  8.  
  9. // IMPORTANT: 
  10. // If you add this script to a script-library or script-archive 
  11. // you have to add a link to http://www.24fun.com on the webpage 
  12. // where this script will be running.
  13.  
  14. // CONFIGURATION:
  15. // Go to www.24fun.com, open category 'utility' and download 
  16. // the full-version of this script as ZIP-file with
  17. // step-by-step instructions for non-programmers.
  18.  
  19. var isNav, isIE, isFF;
  20. var offsetX, offsetY;
  21. var selectedObj; 
  22.  
  23. var largewidth = 0;
  24. var largeheight = 0;
  25.  
  26. var thumbwidth = Math.floor(largewidth/shrinkfactor);
  27. var thumbheight = Math.floor(largeheight/shrinkfactor);
  28.  
  29. var dragimgwidth = Math.floor(clipwidth/shrinkfactor);
  30. var dragimgheight = Math.floor(clipheight/shrinkfactor);
  31. var dragimgleft = thumbleft+3;
  32. var dragimgtop = thumbtop+3;
  33.  
  34. var difleft= largeleft-thumbleft;
  35. var diftop= largetop-thumbtop;
  36.  
  37. var clippoints;
  38.  
  39. var cliptop=0;
  40. var clipbottom=cliptop+clipheight;
  41. var clipleft=0;
  42. var clipright=clipleft+clipwidth;
  43.  
  44.  
  45. if (parseInt(navigator.appVersion) >= 4) {
  46.     if (navigator.appName == "Netscape") {
  47.         isNav = true;
  48.     } else {
  49.         isIE = true;
  50.     }
  51. }
  52.  
  53.  
  54. if (navigator.userAgent.indexOf("Opera")!=-1 && document.getElementById) type="OP";        //Opera
  55.     else if (document.all) isNav = true;                                                        //Internet Explorer e.g. IE4 upwards
  56.     else if (document.layers) type="NN";                                                    //Netscape Communicator 4
  57.     else if (!document.all && document.getElementById) isFF=true;                            //Mozila e.g. Netscape 6 upwards
  58.     else isIE = true;        //I assume it will not get here
  59.  
  60.  
  61.  
  62. function setZIndex(obj, zOrder) {
  63.     obj.zIndex = zOrder;
  64. }
  65.  
  66. function shiftTo(obj, x, y) {
  67.     if (document.layers) {
  68.         if(x<=document.thumb.left) {x=document.thumb.left};
  69.         if(x>=(document.thumb.left+thumbwidth-dragimgwidth-2)) {x=document.thumb.left+thumbwidth-dragimgwidth-2};
  70.         if(y<=document.thumb.top) {y=document.thumb.top};
  71.         if(y>=(document.thumb.top+thumbheight-dragimgheight-2)) {y=document.thumb.top+thumbheight-dragimgheight-2};
  72.         obj.moveTo(x,y);
  73.     } else {
  74.         if(x<=document.getElementById("thumb").style.posLeft) {x=document.getElementById("thumb").style.posLeft};
  75.         if(x>=(document.getElementById("thumb").style.posLeft+thumbwidth-dragimgwidth-2)) {x=document.getElementById("thumb").style.posLeft+thumbwidth-dragimgwidth-2};
  76.         if(y<=document.getElementById("thumb").style.posTop) {y=document.getElementById("thumb").style.posTop};
  77.         if(y>=(document.getElementById("thumb").style.posTop+thumbheight-dragimgheight-2))  {y=document.getElementById("thumb").style.posTop+thumbheight-dragimgheight-2};
  78.         obj.pixelLeft = x;
  79.         obj.pixelTop = y;
  80.     }    
  81.     cliptop = (y-thumbtop)*shrinkfactor;
  82.     clipbottom = cliptop+clipheight;
  83.     clipleft = (x-thumbleft)*shrinkfactor;
  84.     clipright = clipleft+clipwidth;
  85.  
  86.  
  87.     if (document.all) {
  88.         clippoints ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
  89.         document.all.large.style.posTop=largetop-cliptop;
  90.         document.all.large.style.posLeft=largeleft-clipleft;
  91.         document.all.large.style.clip=clippoints;
  92.     }
  93.     if (document.layers) {
  94.         document.large.top=largetop-cliptop;
  95.         document.large.left=largeleft-clipleft;
  96.         document.large.clip.left = clipleft;
  97.         document.large.clip.right = clipright;
  98.         document.large.clip.top = cliptop;
  99.         document.large.clip.bottom = clipbottom;
  100.     }
  101.     if (document.getElementById()) {
  102.         clippoints ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
  103.         document.getElementById("large").style.posTop=largetop-cliptop;
  104.         document.getElementById("large").style.posLeft=largeleft-clipleft;
  105.         document.getElementById("large").style.clip=clippoints;
  106.     }
  107. }
  108.  
  109. function setSelectedElem(evt) {
  110.     if (document.layers) {
  111.         var testObj;
  112.         var clickX = evt.pageX;
  113.         var clickY = evt.pageY;
  114.         for (var i = document.layers.length - 1; i >= 0; i--) {
  115.             testObj = document.layers[i];
  116.             if ((clickX > testObj.left) && 
  117.                 (clickX < testObj.left + testObj.clip.width) && 
  118.                 (clickY > testObj.top) && 
  119.                 (clickY < testObj.top + testObj.clip.height && document.layers[i].id=="dragimg")) {
  120.                     selectedObj = testObj;
  121.                     setZIndex(selectedObj, 100);
  122.                     return;
  123.             }
  124.         }
  125.     } else {
  126.  
  127.         var imgObj = (evt.imgObj) ? evt.imgObj : evt.srcElement;
  128.         if (imgObj.parentElement.id.indexOf("dragimg") != -1) {
  129.             selectedObj = imgObj.parentElement.style;
  130.             setZIndex(selectedObj,100);
  131.             return;
  132.         }
  133.     }
  134.     selectedObj = null;
  135.     return;
  136. }
  137.  
  138. function dragIt(evt) {
  139.     if (selectedObj) {
  140.         if (document.layers) {
  141.             shiftTo(selectedObj, (evt.pageX - offsetX), (evt.pageY - offsetY));
  142.         } else {
  143.             shiftTo(selectedObj, ((window.event) ? window.event :clientX - offsetX), ((window.event) ? window.event : clientY - offsetY));
  144.             return false;
  145.         }
  146.     }
  147. }
  148.  
  149. function engage(evt) {
  150.     setSelectedElem(evt);
  151.     if (selectedObj) {
  152.         if (document.layers) {
  153.             offsetX = evt.pageX - selectedObj.left;
  154.             offsetY = evt.pageY - selectedObj.top;
  155.         } else {
  156.             offsetX = (window.event) ? window.event : offsetX;
  157.             offsetY = (window.event) ? window.event : offsetY + 150;
  158.         }
  159.     }
  160.     return false;
  161. }
  162.  
  163. function release(evt) {
  164.     if (selectedObj) {
  165.         setZIndex(selectedObj, 0);
  166.         selectedObj = null;
  167.     }
  168. }
  169.  
  170. function setNavEventCapture() {
  171.     if (document.layers) {
  172.         document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
  173.     }
  174. }
  175.  
  176. function init() {
  177.     if (document.layers) {
  178.         var imageurl=document.large.document.largepic.src;
  179.         largewidth=document.large.document.width;
  180.         largeheight=document.large.document.height;
  181.         thumbwidth = Math.floor(largewidth/shrinkfactor);
  182.         thumbheight = Math.floor(largeheight/shrinkfactor);
  183.         document.thumb.document.write("<IMG NAME='thumbpic' SRC='"+imageurl+"' width="+thumbwidth+"  height="+thumbheight+">");
  184.         document.thumb.document.close();
  185.         document.dragimg.document.write("<IMG NAME='dragimgpic' border=2 SRC='dragimg.gif' width="+dragimgwidth+" height="+dragimgheight+">");
  186.         document.dragimg.document.close();
  187.         document.large.left=largeleft;
  188.         document.large.top=largetop;
  189.  
  190.         document.thumb.left=thumbleft;
  191.         document.thumb.top=thumbtop;
  192.  
  193.         document.dragimg.left=dragimgleft;
  194.         document.dragimg.top=dragimgtop;
  195.  
  196.         document.large.clip.left=clipleft;
  197.         document.large.clip.right=clipright;
  198.         document.large.clip.top=cliptop;
  199.         document.large.clip.bottom=clipbottom;
  200.         document.large.visibility="visible";
  201.  
  202.         setNavEventCapture();
  203.     }
  204.     if (document.all) {
  205.         var imageurl=document.largepic.src;
  206.         largewidth=document.all.large.offsetWidth;
  207.         largeheight=document.all.large.offsetHeight;
  208.         thumbwidth = Math.floor(largewidth/shrinkfactor);
  209.         thumbheight = Math.floor(largeheight/shrinkfactor);
  210.         thumb.innerHTML="<IMG NAME='thumbpic' SRC='"+imageurl+"' width="+thumbwidth+"  height="+thumbheight+">";
  211.         dragimg.innerHTML="<IMG NAME='dragimgpic' border=2 SRC='dragimg.gif' width="+dragimgwidth+"  height="+dragimgheight+">";
  212.  
  213.         document.all.large.style.posLeft=largeleft;
  214.         document.all.large.style.posTop=largetop;
  215.  
  216.         document.all.thumb.style.posLeft=thumbleft;
  217.         document.all.thumb.style.posTop=thumbtop;
  218.  
  219.         document.all.dragimg.style.posLeft=dragimgleft;
  220.         document.all.dragimg.style.posTop=dragimgtop;
  221.         clippoints ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
  222.         document.all.large.style.clip=clippoints;
  223.         document.all.large.style.visibility="visible";
  224.     }
  225.  
  226.     if (document.getElementById) {
  227.         var imageurl=document.largepic.src;
  228.         largewidth=document.getElementById("large").offsetWidth;
  229.         largeheight=document.getElementById("large").offsetHeight;
  230.         thumbwidth = Math.floor(largewidth/shrinkfactor);
  231.         thumbheight = Math.floor(largeheight/shrinkfactor);
  232.         thumb.innerHTML="<IMG NAME='thumbpic' SRC='"+imageurl+"' width="+thumbwidth+"  height="+thumbheight+">";
  233.         dragimg.innerHTML="<IMG NAME='dragimgpic' border=2 SRC='dragimg.gif' width="+dragimgwidth+"  height="+dragimgheight+">";
  234.  
  235.         document.getElementById("large").style.posLeft=largeleft;
  236.         document.getElementById("large").style.posTop=largetop;
  237.  
  238.         document.getElementById("thumb").style.posLeft=thumbleft;
  239.         document.getElementById("thumb").style.posTop=thumbtop;
  240.  
  241.         document.getElementById("dragimg").style.posLeft=dragimgleft;
  242.         document.getElementById("dragimg").style.posTop=dragimgtop;
  243.         clippoints ="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")";
  244.         document.getElementById("large").style.clip=clippoints;
  245.         document.getElementById("large").style.visibility="visible";
  246.     }
  247.  
  248.     document.onmousedown = engage;
  249.     document.onmousemove = dragIt;
  250.     document.onmouseup = release;
  251. }
  252.  
  253. window.onload=init;
Jul 17 '06 #1
1 6867
acoder
16,027 Expert Mod 8TB
posLeft/Top should be replaced by left/top.

When setting these positioning style properties, don't forget the units, e.g. "px". If you need the values afterwards, use parseInt to get the integer values.
Apr 30 '08 #2

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

Similar topics

15
by: Applebrown | last post by:
I've got a couple of errors on my site that I'm not sure how to fix. I'm using simple CSS for both text rollovers and my horizontal navbar, and here's what happens. First, the site: ...
5
by: Csaba Gabor | last post by:
Is there any way to determine the pixel height and width of an original image? Specifically, If I have <IMG id=myImg src="pic.jpg" height=200 width=300> can I figure out what the original size...
4
by: zborisau | last post by:
Hey good people, I've been given a problem to solve recently - and stuck with the solution for a good 4 days already. i have a link which leads to popup window. the purpose of that popup...
6
by: cjl | last post by:
I have a website which allows people to view interesting radiology cases. It is for teaching radiology residents. It is designed to run in fullscreen or 'kiosk' mode, at 1024 x 768 resolution...
7
by: cjl | last post by:
OK: I am really scratching my head over a preload / image swapping problem, so I started conducting experiments: http://www.saintrays.net/experiment1.html...
2
by: neuneudr | last post by:
Hi all, I've been trying JavaScript a little bit. I beginned by changing an image using a very simple: document.getElementById(...).src="new image" Which worked fine. However this does...
1
by: loupet | last post by:
Hello all I am new here and this is my first post. I have tried several javascripts to preview an image on a web page using the "input type=file" to Browse and preview the image. Using IE...
1
by: ntombikayise | last post by:
Hi, I urgently need help. My code should let a user select an image file for upload, view the image on the browser to be able to set the image size then upload the image. It should also be...
7
by: fredo | last post by:
I've studied Eric Meyer's pure css popups, version two: http://meyerweb.com/eric/css/edge/popups/demo2.html which pops up an image when I roll over a text link. Now I want to pop up a large...
5
by: Steve JORDI | last post by:
Just a question using images as submit buttons and PHP4.4.4. It seems that my code correctly works in FireFox but not in IExplorer. For example, I have a FORM with 2 buttons called "search" and...
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...
1
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.