Showing posts from February, 2007

How to test javascript performance time

First, create area where results will be output. You can adjust any style property to fit your needs. Minimum what you need to change is "parentNodeId": // Test env function testEnv() {  var parentNode = document.getElementById("parentNodeId");  if (parentNode) {   var testNode = document.createElement("div"); = "testEnv"; = "7em"; = "white"; = "auto"; = "1px solid #778899"; = "left"; = "hidden"; = "nowrap";   parentNode.appendChild(testNode);  } } Then, in the function or any piece of the code you are testing, write: in the beginning: var beginTime = new Date().valueOf(); and finally, at the end: if (document.getElementById("testEnv"))   document.getElementById("

"The webpage you are viewing is trying to close this window"

In Internet Explorer 6 there is the way to close window by javascript without warning: "The webpage you are viewing is trying to close this window": window.opener = top; window.close(); But not in IE 7 unless window was opened by your javascript from other window.

Adding event listener on the page

Suppose you have an input field and you need FilerTag function be performed each time user types a character. Below are two approaches for this. Native browser approach: if (a.addEventListener) {a.addEventListener("keyup", FilterTags, false)} // firefox else if (a.attachEvent) {a.attachEvent("onpropertychange", FilterTags)} // ie YUI approach: YAHOO.util.Event.addListener(a, "keyup", FilterTags);