本文介绍了JavaScript的backspace默认问题....回头一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是我的源代码...

这里是网页:

我遇到的问题是,当您在列表中键入电话号码列表,然后当您单击一个电话号码进行编辑时,如果退格键删除号码,则会通过返回一页来混淆整个列表。 ...我完全意识到这是因为默认的后台页面是退格键,这就是为什么它会这样做,但我真的希望它不会倒退,当我使用退格键从列表中删除一个数字时.....

The issue I am having is when you type a list of phone numbers into the list and then when you click one to edit it, if you backspace to delete the number, it will mess the entire list up by going back one page....i am fully aware that this is because the default back page is backspace and thats why its doing that but I really want it to not backpage when I use backspace to delete a number from the list.....

所以我说的基本上是我怎样才能禁止退格到后台......

So what I am saying basically is how can I disable backspace to backpage......

推荐答案

在输入的keyup事件中,处理keyCode,如果它是退格,只需stub p由返回false; 引起的冒泡(冒泡)。当您退格一个元素时,keyup事件将从该元素移至其父元素,移至其父元素父元素,移至其祖父元素的父元素,依此类推。这叫做冒泡。如果你处理它,并且返回false; ,你声明你不希望它(事件)被传递给父母。
当一个keyup到达主体(或HTML,或文档或窗口)时,它会触发window.history.prev()方法,该方法会将一个页面移回。

On the keyup event of the input, handle the keyCode and if it was a backspace, simply stub propagation (bubbling) by return false;. When you backspace on an element, the keyup event is moved from the element to its parent, to its parent's parent, to its grandparent's parent element and so on. This is called bubbling. If you handle it, and return false;, you declare that you don't want it (the event) to be passed to parents. When a keyup reaches the body (or HTML, or document, or window), it fires window.history.prev() method, which moves one page back.

这篇关于JavaScript的backspace默认问题....回头一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 17:46