input按钮的事件处理大全

2018-08-22 19:07 更新

1.<INPUT onclick=document.all.WebBrowser.ExecWB(1,1) type=button value=打开 name=Button1> 


2.<INPUT onclick=document.all.WebBrowser.ExecWB(4,1) type=button value=另存为 name=Button2> 


3.<INPUT onclick=document.all.WebBrowser.ExecWB(10,1) type=button value=属性 name=Button3> 


4.<INPUT onclick=document.all.WebBrowser.ExecWB(6,1) type=button value=打印 name=Button> 


5.<INPUT onclick=document.all.WebBrowser.ExecWB(8,1) type=button value=页面设置 name=Button4> 


6.<INPUT onclick=window.location.reload() type=button value=刷新 name=refresh> 


7.<INPUT onclick="window.external.ImportExportFavorites(true,'');" type=button value=导入收藏夹 name=Button5> 


8.<INPUT onclick="window.external.ImportExportFavorites(false,'');" type=button value=导出收藏夹 name=Button32> 


9.<INPUT onclick="window.external.AddFavorite(location.href, document.title)" type=button value=加入收藏夹 name=Button22> 


10.<INPUT onclick="window.external.ShowBrowserUI('OrganizeFavorites', null)" type=button value=整理收藏夹 name=Submit2> 


11.<INPUT onclick='window.location="view-source:" + window.location.href' type=button value=查看源文件 name=Button7> 


12.<INPUT onclick="window.external.ShowBrowserUI('LanguageDialog', null)" type=button value=语言设置 name=Button6> 


13.<INPUT onclick="document.execCommand('Cut')" type=button value=剪切> 


14.<INPUT onclick="document.execCommand('Copy')" type=button value=拷贝> 


15.<INPUT onclick="document.execCommand('Paste')" type=button value=粘贴> 


16.<INPUT onclick="document.execCommand('Undo')" type=button value=撤消> 


17.<INPUT onclick="document.execCommand('Delete')" type=button value=删除> 


18.<INPUT onclick="document.execCommand('Bold')" type=button value=黑体> 


19.<INPUT onclick="document.execCommand('Italic')" type=button value=斜体> 


20.<INPUT onclick="document.execCommand('Underline')" type=button value=下划线> 


21.<INPUT onclick="document.execCommand('stop')" type=button value=停止> 


22.<INPUT onclick="document.execCommand('SaveAs')" type=button value=保存> 


23.<INPUT onclick="document.execCommand('Saveas',false,'c:\\test.htm')" type=button value=另存为> 


24.<INPUT onclick="document.execCommand('FontName',false,fn)" type=button value=字体> 


25.<INPUT onclick="document.execCommand('FontSize',false,fs)" type=button value=字体大小> 


26.<INPUT onclick="document.execCommand('refresh',false,0)" type=button value=刷新> 


27.<INPUT onclick=window.location.reload() type=button value=刷新> 


28.<INPUT onclick=history.go(1) type=button value=前进> 


29.<INPUT onclick=history.go(-1) type=button value=后退> 


30.<INPUT onclick=history.forward() type=button value=前进> 


31.<INPUT onclick=history.back() type=button value=后退> 


32.<INPUT onclick='window.external.ImportExportFavorites(true,"http://localhost";);' type=button value=导入收藏夹> 


33.<INPUT onclick='window.external.ImportExportFavorites(false,"http://localhost";);' type=button value=导出收藏夹> 


34.<INPUT onclick="window.external.ShowBrowserUI('OrganizeFavorites', null)" type=button value=整理收藏夹> 


35.<INPUT onclick="window.location = 'view-source:'+ window.location.href" type=button value=查看源文件> 


36.<INPUT onclick="window.external.ShowBrowserUI('LanguageDialog', null)" type=button value=语言设置> 


37.<INPUT onclick="window.external.AddFavorite('http://www.jb51.net', 十万个为什么)" type=button value=加入收藏夹> 


38.<INPUT onclick="window.external.addChannel('http://www.jb51.net')" type=button value=加入到频道> 


39.<INPUT onclick="this.style.behavior='url(#default#homepage)';this.setHomePage('http://www.jb51.net/')" type=button value=设成主页>



利用input工具发送按钮事件


有时候在Android开发测试过程中需要用到按键事件,但由于其它原因不是很方便每次都用键盘或鼠标去点击,这里介绍一下利用input工具的方法.

使用input工具其实很简单,首先进入adb shell,然后输入:
[plain] view plain copy
#input keyevent <keycode>  
或者直接在终端下输入:
[plain] view plain copy
$adb shell input keyevent <keycode>  
其中<keycode>表示按键代码,它值在$ANDOIRD/frameworks/base/include/ui/KeycodeLabels.h头文件中定义,如下:

static const KeycodeLabel KEYCODES[] = {  
    { "SOFT_LEFT", 1 },  
    { "SOFT_RIGHT", 2 },  
    { "HOME", 3 },  
    { "BACK", 4 },  
    { "CALL", 5 },  
    { "ENDCALL", 6 },  
    { "0", 7 },  
    { "1", 8 },  
    { "2", 9 },  
    { "3", 10 },  
    { "4", 11 },  
    { "5", 12 },  
    { "6", 13 },  
    { "7", 14 },  
    { "8", 15 },  
    { "9", 16 },  
    { "STAR", 17 },  
    { "POUND", 18 },  
    { "DPAD_UP", 19 },  
    { "DPAD_DOWN", 20 },  
    { "DPAD_LEFT", 21 },  
    { "DPAD_RIGHT", 22 },  
    { "DPAD_CENTER", 23 },  
    { "VOLUME_UP", 24 },  
    { "VOLUME_DOWN", 25 },  
    { "POWER", 26 },  
    { "CAMERA", 27 },  
    { "CLEAR", 28 },  
    { "A", 29 },  
    { "B", 30 },  
    { "C", 31 },  
    { "D", 32 },  
    { "E", 33 },  
    { "F", 34 },  
    { "G", 35 },  
    { "H", 36 },  
    { "I", 37 },  
    { "J", 38 },  
    { "K", 39 },  
    { "L", 40 },  
    { "M", 41 },  
    { "N", 42 },  
    { "O", 43 },  
    { "P", 44 },  
    { "Q", 45 },  
    { "R", 46 },  
    { "S", 47 },  
    { "T", 48 },  
    { "U", 49 },  
    { "V", 50 },  
    { "W", 51 },  
    { "X", 52 },  
    { "Y", 53 },  
    { "Z", 54 },  
    { "COMMA", 55 },  
    { "PERIOD", 56 },  
    { "ALT_LEFT", 57 },  
    { "ALT_RIGHT", 58 },  
    { "SHIFT_LEFT", 59 },  
    { "SHIFT_RIGHT", 60 },  
    { "TAB", 61 },  
    { "SPACE", 62 },  
    { "SYM", 63 },  
    { "EXPLORER", 64 },  
    { "ENVELOPE", 65 },  
    { "ENTER", 66 },  
    { "DEL", 67 },  
    { "GRAVE", 68 },  
    { "MINUS", 69 },  
    { "EQUALS", 70 },  
    { "LEFT_BRACKET", 71 },  
    { "RIGHT_BRACKET", 72 },  
    { "BACKSLASH", 73 },  
    { "SEMICOLON", 74 },  
    { "APOSTROPHE", 75 },  
    { "SLASH", 76 },  
    { "AT", 77 },  
    { "NUM", 78 },  
    { "HEADSETHOOK", 79 },  
    { "FOCUS", 80 },  
    { "PLUS", 81 },  
    { "MENU", 82 },  
    { "NOTIFICATION", 83 },  
    { "SEARCH", 84 },  
    { "MEDIA_PLAY_PAUSE", 85 },  
    { "MEDIA_STOP", 86 },  
    { "MEDIA_NEXT", 87 },  
    { "MEDIA_PREVIOUS", 88 },  
    { "MEDIA_REWIND", 89 },  
    { "MEDIA_FAST_FORWARD", 90 },  
    { "MUTE", 91 },  
    { "PAGE_UP", 92 },  
    { "PAGE_DOWN", 93 },  
    { "PICTSYMBOLS", 94 },  
    { "SWITCH_CHARSET", 95 },  
    { "BUTTON_A", 96 },  
    { "BUTTON_B", 97 },  
    { "BUTTON_C", 98 },  
    { "BUTTON_X", 99 },  
    { "BUTTON_Y", 100 },  
    { "BUTTON_Z", 101 },  
    { "BUTTON_L1", 102 },  
    { "BUTTON_R1", 103 },  
    { "BUTTON_L2", 104 },  
    { "BUTTON_R2", 105 },  
    { "BUTTON_THUMBL", 106 },  
    { "BUTTON_THUMBR", 107 },  
    { "BUTTON_START", 108 },  
    { "BUTTON_SELECT", 109 },  
    { "BUTTON_MODE", 110 },  
// NOTE: If you add a new keycode here you must also add it to several other files.  
    //       Refer to frameworks/base/core/java/android/view/KeyEvent.java for the full list.  
  
    { NULL, 0 }  
};   


input工具不仅在adb shell下使用,在C/C++代码中也可以使用:

sprintf(s_keyArray, "input keyevent %d", keycode);  
system(s_keyArray);  
这样的话,可以直接向系统发送按键事件。

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号