[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

html code for Mozilla firefox

Posted on 2005-04-27
5
Medium Priority
?
1,241 Views
Last Modified: 2013-11-19
I have written the following code on the OnbeforeunLoad event of body
<HTML>
:
:
:
<script language =javascript>
function performTask()
{
alert(event.clientY);
}
</script>

:
:
<body onbeforeUnLoad="javascript:performTask()">
:
:
:
:
</body>
</HTML>
the code works well with IE but doesn't work with Mozilla firefox (Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.6) Gecko/20050225 Firefox/1.0.1)



thanks in advance if any one can provide me with the solution...
0
Comment
Question by:alphamn
3 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 13875181
That is non-standard IE only event.  There is no way to implement anything similar in other browsers.

Cd&
0
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 13877641
The following link is for firefox open source code page....

http://www.mozilla.org/hacking/

i guess this may help u to some extent.
0
 
LVL 4

Accepted Solution

by:
ARCglide earned 200 total points
ID: 13881067
This is the closest I can get to using your original code and workinhg within IE6 and Firefox1.0.3 (not in Opera8)
------------------
<html>
<head>
<script>
// Global variables
mouseX=0; // Horizontal position of mouse on screen
mouseY=0; // Vertical position of mouse on screen
mouseXmax=0; // Maximium Horizontal mouse position (page width)
mouseYmax=0; // Maximium Vertical mouse position (page height)

if(document.layers){ // Netscape
    document.captureEvents(Event.MOUSEMOVE);
    document.onmousemove = captureMousePosition; }
else if(document.all){ // Internet Explorer
    document.onmousemove = captureMousePosition; }
else if(document.getElementById){ // Netcsape 6
    document.onmousemove = captureMousePosition; }

function captureMousePosition(e) {
    if(document.layers){
        mouseX = e.pageX;
        mouseY = e.pageY;
        mouseXmax = window.innerWidth+window.pageXOffset;
        mouseYmax = window.innerHeight+window.pageYOffset; }
    else if(document.all){
        mouseX = window.event.x+document.body.scrollLeft;
        mouseY = window.event.y+document.body.scrollTop;
        mouseXmax = document.body.clientWidth+document.body.scrollLeft;
        mouseYmax = document.body.clientHeight+document.body.scrollTop; }
    else if(document.getElementById){
        mouseX = e.pageX;
        mouseY = e.pageY;
        mouseXmax = window.innerWidth+window.pageXOffset;
        mouseYmax = window.innerHeight+window.pageYOffset;
    }
}

function performTask(){
alert(mouseY);
}
</script>
</head>
<body onbeforeunload="performTask();">
... body ...
</body>
</html>
------------------
Fully commented Reference:
http://www.breakingpar.com/bkp/home.nsf/0/87256B14007C5C6A87256B4B0005BFA6

Usage: Save and Load up this page in IE / Firefox ad hit refresh to fire the onbeforeunload event

Hope that helps ... :-)

--ARCglide
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
This video teaches users how to migrate an existing Wordpress website to a new domain.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses
Course of the Month18 days, 7 hours left to enroll

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question