SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 116 | Next

Jonathan Snook, Aaron Gustafson, Stuart Langridge, and Dan Webb

"Accelerated DOM Scripting with Ajax, APIs, and Libraries"

getElementById('mylink'),
'This link will open in a new window!' );
Using the addListener() function from the previous chapter, the openWin() function was
attached as the event handler. However, because of the closure, openWin() still has access to
the message argument after the event has been fired.
Once you get comfortable with closures, you might find yourself avoiding the use of this
more often.
Closures have a bit of a stigma because of the way Internet Explorer (IE) handles them
in conjunction with working with DOM objects. IE has traditionally had trouble releasing the
memory when a closure is used in this way, even after navigating away from the current page.
It requires the browser to be restarted to regain this memory. Microsoft resolved this problem
in IE 7; it then released a patch in June 2007 for IE 6 that resolved memory leaks in that
browser. Unfortunately, the patch applied only to those running IE 6 on Windows XP. Older
machines or those that don??™t have the patch installed still have memory issues.
You might not notice the memory leak in a small application, and it would require a lot
of executions to see a large impact on system performance. When you get into larger appli-
CHAPTER 3 n OBJECT-ORIENTED PROGRAMMING 70
cations, though, users tend to spend more time on a single page that does a lot more DOM
manipulation and event handling. The likelihood is therefore much higher that it can have an
impact on your customers??”especially these days, when people are less and less likely to close
down their browsers on a regular basis.


Pages:
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128