Skip to content

Instantly share code, notes, and snippets.

@nobuoka
Created May 16, 2012 17:11
Show Gist options
  • Save nobuoka/2712290 to your computer and use it in GitHub Desktop.
Save nobuoka/2712290 to your computer and use it in GitHub Desktop.
Chrome 拡張の popup 内で confirm を使うとおかしくなることがある
{
"name": "Extension for test",
"version": "1.0",
"manifest_version": 2,
"description": "for test of alert, confirm and prompt functions",
"browser_action": {
"default_popup": "popup.html"
},
"permissions": [
]
}
<!DOCTYPE html>
<html>
<head>
<title>test</title>
<script src="popup.js"></script>
</head>
<body>
<form id="test-form">
<div>
<input type="submit" id="test-input">
</div>
</form>
</body>
</html>
document.addEventListener( "DOMContentLoaded", function listener( evt ) {
var e = document.getElementById( "test-form" );
e.addEventListener( "submit", function listener( evt ) {
// confirm( "ok?" );
}, false );
e = document.getElementById( "test-input" );
e.addEventListener( "click", function listener( evt ) {
confirm( "ok?" );
}, false );
}, false );
setTimeout( function callback() {
confirm( "okok?" );
}, 2000 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment