This article is more than 1 year old

Web-app devs note: Google wants to banish JavaScript dialogues

Do you really want to leave this malware-serving page? No/No

Annoying sites that open hard-to-eradicate “Do you want to leave this site? Are you sure?” dialogues are in Chrome's cross-hairs: the Chrome team has decided JavaScript dialogues offer too much scope for abuse, and is laying out a roadmap to get rid of them.

The JavaScript dialogue is also a favourite of “Your Computer May Be Infected!” scammers (there's a Malwarebytes note from February here), with simple non-expert users easily sent off to malware domains if they fall for the scumware.

Since people also happen to write non-malicious applications that use JavaScript dialogues, the Chrome bods are giving warning of what they have in mind here.

Instead of app-modal JavaScript, the post asks developers to consider using:

  • The Notifications API, if you're just popping up an event notification;
  • HTML's <dialog> tag for collecting user input; and;
  • For researchers running cross-site-scripting proofs, there's devtool's console.log(document.origin).

On mobile platforms, “if you need to save state, you should use the Page Visibility API”, the post adds.

The team's future plans include changing the alert(), confirm() and prompt() dialogues will no longer be app-modal, but like Safari, dismissed when their tab is switched from – meaning if a JavaScript dialogue is raised, it won't stay on top if you switch tabs.

Finally, “We are investigating the possibility of gating alert()/confirm()/prompt()/onbeforeunload dialogs on site engagement, so if the user isn’t engaging with the page, the page’s dialogs will not be shown. Details have yet to be ironed out.”

Don't say you weren't warned. ®

More about


Send us news

Other stories you might like