/    Sign up×
Community /Pin to ProfileBookmark

Problem with OnBeforeUnload and Browser

Hi, guys

This’s my example code.

[CODE]
<HTML>
<BODY>
<script type=”text/javascript”>
window.onbeforeunload=function (){
document.getElementById(‘image’).innerHTML=”<img src=”img_url”>”;
}
</script>
<div id = “image”></div>
</BODY>
</HTML>[/CODE]

I want onbeforeunload event executed without alert box so I didn’t add ‘return false;’. But it works in Firefox only.

I have tried ‘window.setTimeout’ with onunload and AJAX but it still works in FF only.

Any Suggestion?
TYIA ?

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@toicontienJan 05.2009 — I believe no other browser supports an "onbeforeunload" event. Only onunload is pretty universally supported.
Copy linkTweet thisAlerts:
@felgallJan 05.2009 — Proprietary events such as onbeforeunload are only supported by whichever browser invented the event and any browsers that decide to copy it. As it isn't part of the standards standard compliant browsers will ignore it.
×

Success!

Help @gou-v spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...