本文介绍了回发模拟按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有消息输入屏幕,这引起了我一些问题。在 时刻,有2个按钮,一个用于向另一个用户发送消息 (btnSend),另一个用于向所有用户发送消息(btnSendAll) 。 当用户点击进入时,我也会模拟点击按钮 (btnSend)的效果。但是,我发现btnSend并不会触发(除非我点击 按钮)。 我调用的回发函数如下: 函数__doPostBack(eventTarget,eventArgument) { var theform; if(window.navigator.appName。 toLowerCase()。indexOf(" n etscape")> -1) { theform = document.forms [" Form1"]; } 其他 { theform = document.Form1; } theform.submit(); } 用于引发回发的脚本如下: < script language =" javascript"> var mykey; var posted = false; if(window .Event){ document.captureEvents(Event.KEYDOWN); } document.onkeydown = myKeyDown; 函数myKeyDown(e){ if(window.Event){ mykey = e.which; } else { mykey = event.keyCode; } // alert(mykey); if((mykey == 13)&& (发布==假)) { posted = true; __doPostBack(''btnSend:'',''onclick'' ); } } < / script> 我认为我的问题是要么没有正确指定eventTarget或eventArgument 。有人可以指点一下吗。 很多人不知道I have message entry screen that''s causing me a bit of an issue. At themoment, there are 2 buttons, one is used to send message to another user(btnSend) and another is used to send messages to all users (btnSendAll).When user hits enter, I also simulate the effect of clicking button(btnSend). However, what I found btnSend doesn''t fire (unless I click on thebutton).The postback function I call is as follows:function __doPostBack(eventTarget, eventArgument){var theform;if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1){theform = document.forms["Form1"];}else{theform = document.Form1;}theform.submit();}The script used to cause a postback is as follows:<script language="javascript">var mykey;var posted=false;if (window.Event){document.captureEvents(Event.KEYDOWN);}document.onkeydown = myKeyDown;function myKeyDown(e){if (window.Event){mykey = e.which;}else{mykey = event.keyCode;}//alert(mykey);if ((mykey==13) && (posted==false)){posted=true;__doPostBack(''btnSend:'',''onclick'');}}</script>I think my problem is either not specifying eventTarget or eventArgumentcorrectly. Can someone please give a pointer on this.Many thanx推荐答案 这篇关于回发模拟按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-13 04:17