| OLD | NEW |
| (Empty) |
| 1 <?xml version="1.0"?> | |
| 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
| 3 <head> | |
| 4 <title>Testing Javascript</title> | |
| 5 <script type="text/javascript"> | |
| 6 var seen = {}; | |
| 7 | |
| 8 function updateContent(input) { | |
| 9 document.getElementById('result').innerHTML = "<p>" + input.value +
"</p>"; | |
| 10 } | |
| 11 | |
| 12 function displayMessage(message) { | |
| 13 document.getElementById('result').innerHTML = "<p>" + message + "</p
>"; | |
| 14 } | |
| 15 | |
| 16 function appendMessage(message) { | |
| 17 document.getElementById('result').innerHTML += message + " "; | |
| 18 } | |
| 19 | |
| 20 function register(message) { | |
| 21 if (!seen[message]) { | |
| 22 appendMessage(message); | |
| 23 seen[message] = true; | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 function delayedShowHide(delay, show) { | |
| 28 var blackBox = document.getElementById('clickToHide'); | |
| 29 window.setTimeout(function() { | |
| 30 blackBox.style.display = show ? '' : 'none'; | |
| 31 }, delay); | |
| 32 } | |
| 33 </script> | |
| 34 <script type="text/javascript"> | |
| 35 var startList = function() { | |
| 36 // Ugh. Let's hope no-one is faking their user agent when running th
e tests | |
| 37 if (navigator.userAgent.indexOf("MSIE") != -1) { | |
| 38 var navRoot = document.getElementById("nav"); | |
| 39 for (var i = 0; i < navRoot.childNodes.length; i++) { | |
| 40 var node = navRoot.childNodes[i]; | |
| 41 if (node.nodeName == "LI") { | |
| 42 node.onmouseover = function() { | |
| 43 this.className += " over"; | |
| 44 }; | |
| 45 node.onmouseout = function() { | |
| 46 this.className = this.className.replace(" over", "")
; | |
| 47 }; | |
| 48 } | |
| 49 } | |
| 50 } | |
| 51 }; | |
| 52 window.onload=startList; | |
| 53 </script> | |
| 54 <style type="text/css"> | |
| 55 #nav { | |
| 56 padding: 0; margin: 0; list-style: none; | |
| 57 } | |
| 58 #nav li { | |
| 59 float: left; position: relative; width: 10em; | |
| 60 } | |
| 61 #nav li ul { | |
| 62 display: none; position: absolute; top: 1em; left: 0; | |
| 63 } | |
| 64 #nav li > ul { top: auto; left: auto; } | |
| 65 #nav li:hover ul, #nav li.over ul{ display: block; background: white; } | |
| 66 </style> | |
| 67 </head> | |
| 68 <body> | |
| 69 <h1>Type Stuff</h1> | |
| 70 | |
| 71 <div> | |
| 72 <ul id="nav"> | |
| 73 <li id="menu1">Menu 1 | |
| 74 <ul> | |
| 75 <li id="item1" onclick="displayMessage('item 1');">Item 1</li> | |
| 76 <li>Item 2</li> | |
| 77 </ul> | |
| 78 </li> | |
| 79 </ul> | |
| 80 </div> | |
| 81 | |
| 82 <div id="resultContainer" height="30"> | |
| 83 <div id="result" style="width:300;height:60"> | |
| 84 <p> </p> | |
| 85 </div> | |
| 86 | |
| 87 </div> | |
| 88
| |
| 89 <div id="formageddon"> | |
| 90 <form action="#"> | |
| 91 Key Up: <input type="text" id="keyUp" onkeyup="javascript:updateContent(
this)"/><br/> | |
| 92 Key Down: <input type="text" id="keyDown" onkeydown="javascript:updateCo
ntent(this)"/><br/> | |
| 93 Key Press: <input type="text" id="keyPress" onkeypress="javascript:updat
eContent(this)"/><br/> | |
| 94 Change: <input type="text" id="change" onkeypress="javascript:displayMes
sage('change')"/><br/> | |
| 95 <textarea id="keyDownArea" onkeydown="javascript:updateContent(this)" ro
ws="2" cols="15"></textarea> | |
| 96 <textarea id="keyPressArea" onkeypress="javascript:updateContent(this)"
rows="2" cols="15"></textarea> | |
| 97 <textarea id="keyUpArea" onkeyup="javascript:updateContent(this)" rows="
2" cols="15"></textarea> | |
| 98 <select id="selector" onchange="javascript:updateContent(this)"> | |
| 99 <option value="foo">Foo</option> | |
| 100 <option value="bar">Bar</option> | |
| 101 </select> | |
| 102 <input type="checkbox" id="checkbox" value="checkbox thing" onchange="ja
vascript:updateContent(this)"/> | |
| 103 <input id="clickField" type="text" onclick="document.getElementById('cli
ckField').value='Clicked';" value="Hello"/> | |
| 104 <input id="doubleClickField" type="text" onclick="document.getElementByI
d('doubleClickField').value='Clicked';" ondblclick="document.getElementById('dou
bleClickField').value='DoubleClicked';" oncontextmenu="document.getElementById('
doubleClickField').value='ContextClicked'; return false;" value="DoubleHello"/> | |
| 105 <input id="clearMe" value="Something" onchange="displayMessage('Cleared'
)"/> | |
| 106 </form> | |
| 107 </div> | |
| 108 | |
| 109 <div> | |
| 110 <p><a href="#" onclick="javascript:document.title='Changed'">Change the page
title!</a></p> | |
| 111 | |
| 112 <p><a onclick="javascript:document.title='Changed'" id="nohref">No href</a><
/p> | |
| 113 | |
| 114 <p><a id="updatediv" href="#" onclick="javascript:document.getElementById('d
ynamo').innerHTML = 'Fish and chips!';">Update a | |
| 115 div</a></p> | |
| 116 </div> | |
| 117 | |
| 118 <div id="dynamo">What's for dinner?</div> | |
| 119 | |
| 120 <div id="mousedown" onmousedown="javascript:displayMessage('mouse down');"> | |
| 121 <p>Click for the mouse down event</p> | |
| 122 <span><p id="child">Here's some text</p></span> | |
| 123 </div> | |
| 124 | |
| 125 <div id="mouseup" onmouseup="javascript:displayMessage('mouse up');"> | |
| 126 <p>Click for the mouse up event</p> | |
| 127 </div> | |
| 128 | |
| 129 <div id="mouseclick" onclick="javascript:displayMessage('mouse click');"> | |
| 130 <p>Click for the mouse click event</p> | |
| 131 </div> | |
| 132 | |
| 133 <div id="error" onclick="document.getElementById('doesnotexist').innerHTML = 'ch
eese';"> | |
| 134 Clicking this causes a JS exception in the click handler | |
| 135 </div> | |
| 136 | |
| 137 <div> | |
| 138 <form action="resultPage.html" id="on-form"> | |
| 139 <input id="theworks" | |
| 140 onfocus="appendMessage('focus')" | |
| 141 onkeydown="appendMessage('keydown')" | |
| 142 onkeypress="appendMessage('keypress')" | |
| 143 onkeyup="appendMessage('keyup')" | |
| 144 onblur="appendMessage('blur')" | |
| 145 onchange="appendMessage('change')" | |
| 146 /> | |
| 147 | |
| 148 <input id="changeable" name="changeable" onfocus="appendMessage('focus')" on
change="appendMessage('change')" onblur="appendMessage('blur')"/> | |
| 149 | |
| 150 <button type="button" id="plainButton" | |
| 151 onfocus="appendMessage('focus')" | |
| 152 onkeydown="appendMessage('keydown')" | |
| 153 onkeypress="appendMessage('keypress')" | |
| 154 onkeyup="appendMessage('keyup')" | |
| 155 onblur="appendMessage('blur')" | |
| 156 onclick="appendMessage('click')" | |
| 157 onmousedown="appendMessage('mousedown ')" | |
| 158 onmouseup="appendMessage('mouseup ')" | |
| 159 onmouseover="register('mouseover ')" | |
| 160 onmousemove="register('mousemove ')" | |
| 161 > | |
| 162 <b>Go somewhere</b> | |
| 163 </button> | |
| 164 <button type="submit" id="submittingButton"><emph>submit</emph></button> | |
| 165 <button type="button" id="jsSubmitButton" onclick="javascript:document.getEl
ementById('on-form').submit();">Submitomatic</button> | |
| 166 | |
| 167 <button type="button" id="switchFocus" onclick="document.getElementById('the
works').focus();">Switch focus</button> | |
| 168 <button type="button" onclick="var element = document.getElementById('switch
Focus'); var clickEvent = document.createEvent('MouseEvents'); clickEvent.initMo
useEvent('click', true, true, null, 0, 0, 0, 0, 0,false, false, false, false, 0,
element);element.dispatchEvent(clickEvent);">Do magic</button><br/> | |
| 169 <label id="labelForCheckbox" for="labeledCheckbox" onclick="appendMessage('l
abelclick')">Toggle checkbox</label><input type="checkbox" id="labeledCheckbox"
onclick="appendMessage('chboxclick')"/> | |
| 170 </form> | |
| 171 | |
| 172 <form action="javascriptPage.html" id="submitListeningForm" onsubmit="appendMe
ssage('form-onsubmit '); return false;"> | |
| 173 <p> | |
| 174 <input id="submitListeningForm-text" type="text" onsubmit="appendMessage('
text-onsubmit ')" onclick="appendMessage('text-onclick ');" /> | |
| 175 <input id="submitListeningForm-submit" type="submit" onsubmit="appendMessa
ge('submit-onsubmit ')" onclick="appendMessage('submit-onclick ');" /> | |
| 176 </p> | |
| 177 </form> | |
| 178 </div> | |
| 179 | |
| 180 <p id="suppressedParagraph" style="display: none">A paragraph suppressed using C
SS display=none</p> | |
| 181 | |
| 182 <div> | |
| 183 <p id="displayed">Displayed</p> | |
| 184 | |
| 185 <form action="#"><input type="hidden" name="hidden" /> </form> | |
| 186 | |
| 187 <p id="none" style="display: none;">Display set to none</p> | |
| 188 | |
| 189 <p id="hidden" style="visibility: hidden;">Hidden</p> | |
| 190 | |
| 191 <div id="hiddenparent" style="height: 2em; display: none;"> | |
| 192 <div id="hiddenchild"> | |
| 193 <a href="#" id="hiddenlink">ok</a> | |
| 194 </div> | |
| 195 </div> | |
| 196 | |
| 197 <div style="visibility: hidden;"> | |
| 198 <span> | |
| 199 <input id="unclickable" /> | |
| 200 <input type="checkbox" id="untogglable" checked="checked" />Check box yo
u can't see | |
| 201 </span> | |
| 202 </div> | |
| 203 | |
| 204 <p id="outer" style="visibility: hidden">A <b id="visibleSubElement" style="
visibility: visible">sub-element that is explicitly visible</b> using CSS visibi
lity=visible</p> | |
| 205 </div> | |
| 206 | |
| 207 <div> | |
| 208 <form> | |
| 209 <input type="text" id="keyReporter" size="80" | |
| 210 onkeyup="appendMessage('up: ' + event.keyCode)" | |
| 211 onkeypress="appendMessage('press: ' + event.keyCode)" | |
| 212 onkeydown="displayMessage(''); appendMessage('down: ' + event.key
Code)" /> | |
| 213 <input name="suppress" onkeydown="if (event.preventDefault) event.preven
tDefault(); event.returnValue = false; return false;" onkeypress="appendMessage(
'press');"/> | |
| 214 </form> | |
| 215 </div> | |
| 216 | |
| 217 <!-- Used for testing styles --> | |
| 218 <div style="background-color: green;" id="green-parent"> | |
| 219 <p id="style1">This should be greenish</p> | |
| 220 <ul> | |
| 221 <li id="green-item">So should this</li> | |
| 222 <li id="red-item" style="background-color: red;">But this is red</li> | |
| 223 </ul> | |
| 224 </div> | |
| 225 | |
| 226 <a href="#" id="close" onclick="window.close();">Close window</a> | |
| 227 | |
| 228 <div id="delete" onclick="var d = document.getElementById('deleted'); this.remov
eChild(d);"> | |
| 229 <p id="deleted">I should be deleted when you click my containing div</p> | |
| 230 <p>Whereas, I should not</p> | |
| 231 </div> | |
| 232 | |
| 233 <div> | |
| 234 <span id="hideMe" onclick="this.style.display = 'none';">Click to hide me.</
span> | |
| 235 </div> | |
| 236 | |
| 237 <div style="margin-top: 10px;"> | |
| 238 Click actions delayed by 3000ms: | |
| 239 <div id="clickToShow" onclick="delayedShowHide(3000, true);" | |
| 240 style="float: left;width: 100px;height:100px;border: 1px solid black;"> | |
| 241 Click to show black box | |
| 242 </div> | |
| 243 <div id="clickToHide" onclick="delayedShowHide(3000, false);" | |
| 244 style="float: left;width: 100px;height:100px;border: 1px solid black; | |
| 245 background-color: black; color: white; display: none;"> | |
| 246 Click to hide black box | |
| 247 </div> | |
| 248 <div style="clear: both"></div> | |
| 249 </div> | |
| 250 | |
| 251 <a id="new_window" onmouseup="window.open('closeable_window.html', 'close_me')"
href="#">Click me to open a new window</a> | |
| 252 | |
| 253 <a id="throwing-mouseover" onmouseover="throw new Error()" href="#throwing-mouse
over">Mouse over me will throw a JS error</a> | |
| 254 | |
| 255 <div id="parent"> | |
| 256 <span id="movable" onmouseover="var p = document.getElementById('movable');
displayMessage('parent matches? ' + (p != event.relatedTarget));"> | |
| 257 Click on me to show the related target | |
| 258 </span> | |
| 259 </div> | |
| 260 | |
| 261 <div id="zero" style="width:0;height:0"> | |
| 262 <div> | |
| 263 <img src="map.png"> | |
| 264 </div> | |
| 265 </div> | |
| 266 | |
| 267 </body> | |
| 268 </html> | |
| 269 | |
| 270 | |
| OLD | NEW |