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


html code for Mozilla firefox

Posted on 2005-04-27
Medium Priority
Last Modified: 2013-11-19
I have written the following code on the OnbeforeunLoad event of body
<script language =javascript>
function performTask()

<body onbeforeUnLoad="javascript:performTask()">
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...
Question by:alphamn
LVL 53

Expert Comment

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

LVL 10

Expert Comment

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


i guess this may help u to some extent.

Accepted Solution

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)
// 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.onmousemove = captureMousePosition; }
else if(document.all){ // Internet Explorer
    document.onmousemove = captureMousePosition; }
else if(document.getElementById){ // Netcsape 6
    document.onmousemove = captureMousePosition; }

function captureMousePosition(e) {
        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(){
<body onbeforeunload="performTask();">
... body ...
Fully commented Reference:

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

Hope that helps ... :-)


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