📄 actions.html
字号:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>dhtml menu javascript menu</title> <link rel="stylesheet" href="../code.css" /> </head> <body onload="window.parent.sectionLoaded(document.body)"><div style="font-size: 1px; line-height: 1px"><br /></div><h1>Action handlers</h1><!-- -*- nxml -*- --><p> Albeit very flexible, writing an <a> tag inside every item can sometimes become a pain. For items that open URL-s, writing normal link tags makes sense, because they ought to work in any browser, even text-mode browsers. However, for items that execute JavaScript code dynamically, a more appropriate method can be used, starting with version 2.4 of DynarchMenu.</p><p> While still uses plain HTML syntax in order to setup handlers, <b>unified action handlers</b> allow you to catch events in a single function, and pass to that function enough arguments to help determining what item has been clicked.</p><h2>First off, how do we define the menu?</h2><p> Defining the menu is plain easy, as usual:</p><pre> <<span class="function-name">ul</span> id=<span class="string">"menu"</span> onclick=<span class="string">"master_handler(this)"</span>> <<span class="function-name">li</span>>Item 1<<span class="function-name">/li</span>> <<span class="function-name">li</span>>Item 2<<span class="function-name">/li</span>> <<span class="function-name">li</span>> Item 3 <<span class="function-name">ul</span>> <<span class="function-name">li</span>>SubItem 3.1<<span class="function-name">/li</span>> <<span class="function-name">li</span>>SubItem 3.2<<span class="function-name">/li</span>> <<span class="function-name">/ul</span>> <<span class="function-name">/li</span>> <<span class="function-name">/ul</span>></pre><p> As you can see above, we defined a normal list with items that apparently define no actions. However, there's one special bit: the definition of an <tt>onclick</tt> handler in the toplevel UL element. This handler calls a function defined by you, and passes to it one parameter: 鈥
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -