/    Sign up×
Community /Pin to ProfileBookmark

Cross-browser testing of self-closing popup form window.

Cross-browser testing of self-closing popup form window.

I posted this question under the javascript forum and got some good help.
Upon reflection, my question is DHTML in nature; cross-browser testing of dynamic, self closing window containing a form, using the onBlur event.

A simple onBlur/focus approach fails when the user clicks to fill in the form fields.
So, the code below tries to correct this by delaying the close call and modifying the documents elements’ onFocus events to cancel the close call before it occurs.

It seems to work on IE6, Netscape 7, Mozilla Firefox 1.0 and Opera 7.53.
And it fails gracefully in Netscape 4, I was told by Jona.

I would like some help to check this code out on other browsers you and on Macs if possible.
I would appreciate your help and comments.

Here is a test link: [URL=http://www.gypsytrader.com/jstesting/parent.html].: Test Link :.[/URL]

And here is that code in the popup window:

[CODE]<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>
<HTML>
<HEAD>
<SCRIPT>
var tid;
function closeWin() { tid=setTimeout(‘window.close()’,30); }
function cancelCloseWin(evt) { clearTimeout(tid); }
window.onblur=closeWin;
if(document.layers) {
window.captureEvents(Event.FOCUS);
window.onfocus=function(evt) {
cancelCloseWin(tid);
routeEvent(evt);
};
}
function addFocusHandlers() {
if(document.getElementsByTagName) {
var all=document.body.getElementsByTagName(‘*’);
for(var e=0;e<all.length;e++) {
all[e].onfocus=cancelCloseWin;
}
} else if(document.all) {
for(var e=0;e<document.body.all.length;e++) {
if(document.body.all[e])
document.body.all[e].onFocus=cancelCloseWin;
}
}
}
</script>
</head>
<BODY onLoad=”addFocusHandlers();”>
<FORM NAME=”aForm”>
<INPUT TYPE=”text” NAME=”aField”><br>
<INPUT TYPE=”text” NAME=”bField”><br>
<SELECT NAME=”size”>
<OPTION VALUE=”s”>small
<OPTION VALUE=”m”>medium
<OPTION VALUE=”l”>large
</SELECT>
</form>
</body>
</html>[/CODE]

Thanks,

gsb

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @gsb 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...