Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2009, 02:24 AM
Authorized User
 
Join Date: Dec 2008
Posts: 18
Thanks: 1
Thanked 0 Times in 0 Posts
Default Coordinate issue in Mozilla

Code:
  var isIE = document.all?true:false; if(document.getElementById("ctl00_cphContent_imgMap") != null ) { document.getElementById("ctl00_cphContent_imgMap").onmousedown = getMousePosition; }  function getMousePosition(e) {  var _x;  var _y;  if (!isIE) {   _x = e.pageX ;   _y = e.pageY  }   if (isIE) {   _x = event.clientX + document.body.scrollLeft;  _y = event.clientY + document.body.scrollTop;  }   posX=_x;  posY=_y; }
I call the function from an img onmousedown event I'm able to get the coordiantes in IE and am also able to get it in mozilla too when I getmouseposition onmousedown for the entire body(document.onmousedown) and not just the image area in the body...help appreciated
__________________
Yamini

Last edited by Yamini; July 17th, 2009 at 04:47 AM..
 
Old July 27th, 2009, 06:43 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Not quite sure what you are going for, but try this code instead:
Code:
function GetMousePossition(e)
    {
    var bIsIE = navigator.appName=="Microsoft Internet Explorer";
    var iMouseX = 0;
    var iMouseY = 0;
    if (bIsIE) {iMouseY = event.y; iMouseX = event.x;} else {iMouseY = e.pageY - document.body.scrollTop; iMouseX = e.pageX - document.body.scrollLeft;}
    document.getElementById("Result").innerHTML = "X: " + iMouseX + "  Y: " + iMouseY;
    }
Hope this helped.





Similar Threads
Thread Thread Starter Forum Replies Last Post
mozilla/IE 7 differences Adam H-W CSS Cascading Style Sheets 2 July 9th, 2007 04:16 AM
xmlhttprequest - mozilla alexena XML 0 August 23rd, 2006 07:16 AM
XMLHTTP and Mozilla dazzled XML 1 March 10th, 2006 06:22 AM
pasteHTML() for mozilla ? Farooq Javascript 0 December 21st, 2005 07:39 AM
Mozilla don't support rickytang CSS Cascading Style Sheets 1 September 18th, 2004 03:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.