我正在使用来自http://davidwalsh.name/fullscreen
的这条JS<script>
// Find the right method, call on correct element
function launchFullscreen(element) {
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
var form = $("#my-id");
$("#my-button").click(function () {
// Launch fullscreen for browsers that support it!
launchFullScreen(document.documentElement); // the whole page
form.submit();
});
</script>
如上所述设置click事件的处理程序, HTML如下所示
<form id="my-id" class="form" action="/nextpage" method="post" name="my-name">
<button id="my-button" class="btn btn-default btn-lg">
<span class="glyphicon glyphicon-ok"></span> OK Fullscreen </button>
</form>
表单提交正常但不通过我在脚本部分写的处理程序,为什么以及如何解决这个问题?