From c8cbab2d505e7cdd0bd22bc29321c0c7fa48bb2d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Fri, 25 Sep 2015 15:55:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=81=AB=E7=8B=90=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=20=E5=92=8C=20ie=E6=B5=8F=E8=A7=88=E5=99=A8=E7=9A=84event?= =?UTF-8?q?=E8=8E=B7=E5=BE=97=20=E5=92=8C=20=E9=98=BB=E6=AD=A2=20=E6=96=B9?= =?UTF-8?q?=E5=BC=8F=E4=B8=8D=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/forums/edit.html.erb | 43 ++++++++++++++++++++------------- app/views/forums/index.html.erb | 15 +++++++++--- public/javascripts/new_user.js | 15 +++++++++--- 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/app/views/forums/edit.html.erb b/app/views/forums/edit.html.erb index c212e7b9d..1fcbc6cab 100644 --- a/app/views/forums/edit.html.erb +++ b/app/views/forums/edit.html.erb @@ -1,23 +1,7 @@ <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'new_user' %> \ No newline at end of file diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 8f5cb15cc..bb531b85c 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -49,7 +49,7 @@ $("#reorder_popu").removeClass("sortArrowActiveD"); add_class("reorder_time"); }); - document.getElementById('forum_name').onkeydown = function() + $('#forum_name').keypress( function(e) { var n = 0; var str = this.value; @@ -61,9 +61,16 @@ n += 1;//英文,不多说了 } } - if(n >= 160 && event.keyCode != 8) - event.returnValue = false; - } + if(n >= 160 && e.keyCode != 8) + if(document.all) + { + e.returnValue = false; + } + else + { + e.preventDefault(); + } + }) }); function check_and_submit(doc){ $("#error").html('').hide(); diff --git a/public/javascripts/new_user.js b/public/javascripts/new_user.js index d2b67be5e..22c049ecc 100644 --- a/public/javascripts/new_user.js +++ b/public/javascripts/new_user.js @@ -337,7 +337,7 @@ var autoTextarea = function (elem, extra, maxHeight) { }; function limitStrsize(id,length){ - document.getElementById(id).onkeydown = function() + $('#'+id).keypress(function(e) { var n = 0; var str = this.value; @@ -350,9 +350,16 @@ function limitStrsize(id,length){ } } - if(n >= length && event.keyCode !== 8) - event.returnValue = false; - } + if(n >= length && e.keyCode !== 8) + if(document.all) + { + e.returnValue = false; + } + else + { + e.preventDefault(); + } + }) } /////////////////////////////////////////////////////////////////////////////////////创建项目