我有一个表单,在提交时,我需要在提交表单之前做一些额外的处理.我可以阻止默认表单提交行为,然后进行我的额外处理(它基本上调用Google Maps API并在表单中添加一些隐藏字段) - 然后我需要提交表单.
有没有办法"防止默认",然后某些点"继续默认?"
我写了一个应该在移动设备上运行的html5应用程序.90%的时间它工作正常,但在某些设备(主要是androids 4.0+)中,点击事件会触发两次.
I know why that happens, I'm using iScroll 4 to simulate native scrolling and it handles the events that happen inside the scroll.(line 533 dispatches the event if you're interested) Most of the time it works fine but in certain devices both the iScroll dispatched event and the original onClick event attached to the element are fired, so the click happens twice. I can't find a pattern on which devices this happen so I'm looking for alternatives to …
我想在用户从页面加载时显示加载 gif。我在加载时这样做:
CSS:
.no-js #loader { display: none; }
.js #loader { display: block; position: absolute; left: 100px; top: 0; }
.se-pre-con {
position: fixed;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: 9999;
background: url(https://i.imgur.com/Bpa5eIP.gif) center no-repeat #fff;
}
Run Code Online (Sandbox Code Playgroud)
JavaScript:
<script>
$(window).load(function() {
Animate loader off screen
$(".se-pre-con").fadeOut("slow");;
});
</script>
Run Code Online (Sandbox Code Playgroud)
HTML:
<div class="se-pre-con"></div>
Run Code Online (Sandbox Code Playgroud)
我可以通过向页面上的每个链接添加 .onClick 来做到这一点,但这需要时间,我想知道是否有更简单的方法在加载离开页面时显示 gif。