JavaScript Test : UI Event
To create a simple "UI event" synthetically.
by JS Test
HTML
<script src="https://getfirebug.com/firebug-lite.js"></script>
<h1 id="h1">
Create UI Event
</h1>
<p class="normal" id="p1">
</p>
<input type="button" id="simulateBtn" value=" Simulate Resize">
CSS
h1 {
color: red;
font-size: 24pt;
font-style: italic
}
body {}
.normal {
color: blue;
font-size: 15;
font-family: Arial
}
.visible {
display: none
}
.white {
color: white
}
JavaScript
function simulate(){
var evt = document.createEvent("UIEvent");
evt.initUIEvent("resize",false,false,window,0);
window.dispatchEvent(evt);
}
window.addEventListener("resize", function(){alert("Resized")},false);
document.getElementById("simulateBtn").onclick=simulate;