Hi, I've been playing around with trying to get a popup window to open following a mouse click at the position of the mouse.
The following (hastily put together) code works in IE but Firefox is unresponsive. - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<head>
-
<script language="JavaScript"><!--
-
function showWindow(e) {
-
posx=0;posy=0;
-
var ev=(!e)?window.event:e;//IE:Moz
-
if (ev.pageX){//Moz
-
posx=ev.pageX+window.pageXOffset;
-
posy=ev.pageY+window.pageYOffset;
-
}
-
else if(ev.clientX){//IE
-
posx=ev.clientX+document.body.scrollLeft;
-
posy=ev.clientY+document.body.scrollTop;
-
}
-
else{return false}//old browsers
-
myWindow=window.open('coordinates.html','windowName','width=100,height=100,screenX=' + posx + ',screenY=' + posy + ',left=' + posx + ',top=' + posy);
-
}
-
//--></script>
-
</head>
-
<body>
-
..............................<a href="#" onClick="showWindow();">hxgdfh</a>
-
</body>
-
</html>
BUT... adding in a "document.onclick=showWindow" sees the code working in both browsers (but, obviously, from any click in the window - rather than just the link text) - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<head>
-
<script language="JavaScript"><!--
-
function showWindow(e) {
-
posx=0;posy=0;
-
var ev=(!e)?window.event:e;//IE:Moz
-
if (ev.pageX){//Moz
-
posx=ev.pageX+window.pageXOffset;
-
posy=ev.pageY+window.pageYOffset;
-
}
-
else if(ev.clientX){//IE
-
posx=ev.clientX+document.body.scrollLeft;
-
posy=ev.clientY+document.body.scrollTop;
-
}
-
else{return false}//old browsers
-
myWindow=window.open('coordinates.html','windowName','width=100,height=100,screenX=' + posx + ',screenY=' + posy + ',left=' + posx + ',top=' + posy);
-
}
-
document.onclick=showWindow
-
//--></script>
-
</head>
-
<body>
-
..............................<a href="#" onClick="showWindow();">hxgdfh</a>
-
</body>
-
</html>
Any ideas on making the code work without the "document.onclick=showWindow" would be very helpful.
Thanks!
3 2096
I have had success using:
posx=ev.clientX+pageXOffset;
posy=ev.clientY+pageYOffset;
for the position in Firefox. Hope that helps
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<head>
-
<script language="JavaScript"><!--
-
var posx;var posy;
-
function getMouse(e){
-
posx=0;posy=0;
-
var ev=(!e)?window.event:e;//IE:Moz
-
if (ev.pageX){//Moz
-
posx=ev.pageX+window.pageXOffset;
-
posy=ev.pageY+window.pageYOffset;
-
}
-
else if(ev.clientX){//IE
-
posx=ev.clientX+document.body.scrollLeft;
-
posy=ev.clientY+document.body.scrollTop;
-
}
-
else{return false}//old browsers
-
}
-
document.onmousemove=getMouse
-
function showWindow(e) {
-
myWindow=window.open('coordinates.html','windowName','width=100,height=100,screenX=' + posx + ',screenY=' + posy + ',left=' + posx + ',top=' + posy);
-
}
-
//--></script>
-
</head>
-
<body>
-
<a href="javascript: void(0);" onClick="showWindow();">hxgdfh</a>
-
</body>
-
</html>
-
try this out
Thanks guys - I've sort of answered my own question though.
It seems I was being very sloppy (being a bit of a JS newb) and the link should have been <a href="#" onClick="showWindow(event);">
Thanks for the code though iam_clint, it's definitely a good option!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Greg Bacon |
last post by:
We have a messaging application that makes seemingly unremarkable use
of a HelpProvider component. However, after we've received a message,
if we display the help popup (either via F1 or through...
|
by: MJEASSOC |
last post by:
I need some help with closing a popup window. I'm making an online portfolio,
that has one base page with text and thumbnails. When a user clicks on a thumb,
a new window opens containing a larger...
|
by: Roger Withnell |
last post by:
My simple popup menu code works in IE (Windows and Mac) but not in Safari.
I use a onmouseover ShowMenu function and a onmouseout HideMenu function.
Because Safari, unlike IE, recognises...
|
by: Applebrownbetty |
last post by:
Hi,
I'd like to append/amend the following code from the Dreamweaver extension
"Open Picture Window Fever" for the ability to center the PopUp window:
By default, it allows the window to be...
|
by: jonathon |
last post by:
Hi all,
I have a web app with a popup window for entering data. I don't want
to access the web every time this window is opened, as most of the app
is AJAX. But I can't figure out how to open...
|
by: Colin McGuire |
last post by:
Hi - this was posted last weekend and unfortunately not resolved. The
solutions that were posted almost worked but after another 5 days of
working on the code everynight, I am not further ahead....
|
by: atn2002 |
last post by:
I'm trying to create a control which when the mouse button gets
pressed on one div an absolute positioned div pops up in
place of the cursor. From there the cursor should interact with
the dialog...
|
by: jobs |
last post by:
the javascript:
function ShowTooltip(L1in)
{
document.getElementById("L1").innerText=L1in;
y = event.clientY + document.documentElement.scrollTop;
var Popup= document.getElementById("Popup")...
|
by: johnix |
last post by:
i am a bigenner in this field of web programming.. i like to create a dynamic dropdown menu that the data should came from the database but i dont know how to do it. what i did is I use the table and...
|
by: dheepakk |
last post by:
Hi All,
When a mouseover event takes place over a link the popup window is displayed. I also have a mouseout on the link.So if the popup window comes up,has a dimension such that the...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
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...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: Aftab Ahmad |
last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below.
Dim IE As Object
Set IE =...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
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...
|
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)...
| |