preventdefault

How to prevent 'Overscroll history navigation' without preventing touchstart?

拜拜、爱过 提交于 2019-12-22 09:57:33
问题 I'm implementing a swipe-base navigation, and I'm running into trouble with Chrome. A newly implemented feature, 'Overscroll history navigation', is triggered when the page is dragged to the right, causing a jump back (to 'history -1'). To prevent this, I'd have to call .preventDefault() on touchstart , but this also disables everything from clicking links to scrolling. How do I prevent browser UI events without interfering with the standard page? Disabling the feature altogether by setting

Blocking default action on keypress with iframe

亡梦爱人 提交于 2019-12-21 20:34:10
问题 This is a catch 22 I can't really figure out how to resolve. Take this HTML5 game we host: http://www.scirra.com/arcade/action/93/8-bits-runner - Warning has sound! The page is hosted on scirra.com but the game is in an iframe on static1.scirra.net for security reasons. Now if you press left and right, up or down when you are playing the game the entire window scrolls up and down, left and right. The prevent default seems to work OK when the game isn't focused. We want to prevent this default

HTML Anchor tag redirect link after ajax request

人走茶凉 提交于 2019-12-21 16:55:11
问题 I'm trying to write a method to catch user clicks on a site menu, but I want the process to be silent for the user, mainly, that when a user hovers over an anchor tag, it would behave normally (showing the link it contains). I've tried in various ways to do this, and I almost have it working now, my code is as follows: <div class="selectNode" id="selectNode_1" style="color: rgb(229, 229, 229); background-color: rgb(47, 47, 47); "> <a href="http://www.google.com" class="selectAnchor" style=

event.preventDefault doesn't seem to work

霸气de小男生 提交于 2019-12-20 07:46:16
问题 So im trying to stop a form from refreshing the page and this is the code i'm using: $("#getName").submit(function(refresh) { refresh.preventDefault(); $("#p22").fadeOut(50); $("#p23").fadeIn(800); document.getElementById("p23").innerHTML = "Oh " + userName + ", alright i wont forget that!"; }) I can't seem to get this working properly.... id = getName - is the form id 回答1: Your question is similar to: https://stackoverflow.com/a/6462306/986160 Try this: $("#getName").submit(function(refresh)

Chrome not allowing tab prevendefault

爱⌒轻易说出口 提交于 2019-12-20 05:58:50
问题 I have a form on which user can tab and jump to different elements. i was to stop the tab when it reaches a special anchor tag. this is the code which work in firefox $('.next-tab').keypress(function(e){ var code = (e.keyCode ? e.keyCode : e.which); console.log(code); if (code == 0 || code == 9){ console.log("keypress") e.preventDefault(); e.stopPropagation(); } }); but this code does not work in chrome, i dont know why, it does not even enter the keypress method. so i used this code for

Form still submits on preventDefault

穿精又带淫゛_ 提交于 2019-12-20 05:28:10
问题 I am using jQuery to submit form data to a file in the form's action. However, when I submit the form, the browser redirects to the action (comment.php). I don't know why this is because e.preventDefault() should stop the browser's redirection. Ideally, I would like the browser to not redirect and remain on the current page (index.php). jQuery: <script type='text/javascript'> $('document').ready(function(){ $('.commentContainer').load('../writecomment.php'); $('.answerContainer').on('submit',

preventDefault() won't work for me

笑着哭i 提交于 2019-12-20 04:15:38
问题 Why will this refuse to work? HTML stuff <div id="nav-bar"> <ul> <li> <span> <a href="contact.html">Contact</a> </span> </li> </ul> </div> Javascript stuff $('div#nav-bar').filter('a').click(function(event){ event.preventDefault(); }); 回答1: Filter only filters what is already selected. In your case, the #nav-bar element. You need this: $('div#nav-bar a').click(function(event){ event.preventDefault(); }); 回答2: filter is the wrong method to use here. you should either use find to look for

event.preventDefault() not working in Mozilla or IE

北慕城南 提交于 2019-12-20 03:56:07
问题 I'm finally at the point of testing my site in other browsers (built it mostly in Chrome). Unfortunately, a lot of stuff seems to function differently. I'll begin with the very first problem: upon login, I have a JS/jQuery check to make sure the username and password match, and upon failure it should stop the submission. However, while it works in Chrome and Safari, in Mozilla and IE the submission is still going through (hitting an apology page, but still something I'd rather just not see at

Prevent Default Behavior or A Tag Click Event in JavaScript Inside Ajax Call

拟墨画扇 提交于 2019-12-20 01:39:49
问题 I have used e.preventDefault() in the past to cancel a click event, but I am having trouble figuring out why it isnt working in this scenario. I assigned all a tags in a column with a classname, then get references to them with document.queryselectorAll(.classname) , then for each a tag add a click event that gets values from server, and if validation not met should prevent default and give user message. (function(){ const userName = document.getElementById('FullName').value; // route $route

can e.preventDefault() be reversed?

房东的猫 提交于 2019-12-19 18:48:30
问题 i am looking for a way to .preventDefault() to make a transition and then allow the default behavior $('.withTrans').click(function(e){ e.preventDeault(); $(this).animate('opacity','0',300,function(){ e.resumeDefault(); // does something like this exist? }); }) 回答1: $('.withTrans').click(function(event) { if ( $(this).data("prevented") === true ) { $(this).data("prevented", false); return; } event.preventDefault(); $(this).animate('opacity', '0', 300, function() { $(this).data("prevented",