calendarxp Site Admin
Joined: 30 Jan 2005 Posts: 409
|
Posted: Mon Jul 31, 2006 9:44 pm Post subject: Why I got stack overflow when using the calendar with the dragdrop script lib from www.walterzorn.com? |
|
|
It's because there is a bug in the wz_dragdrop.js file from www.walterzorn.com. You may fix it by removing the line 1326 of the wz_dragdrop.js - it's the last line of function SET_DHTML(), as following:
Code: | function SET_DHTML()
{
...
dd.setDwnHdl(PICK); <--- REMOVE this line of code
} |
The reason behind is the setDwnHdl() already gets called in the dd.initz() which is initialized during window.onload(). Calling it twice will results in endless recursion if the page's onmousedown also setup by other scripts.
Although the author had added a check in setDwnHdl() trying to avoid such recursion within the scope of dragdrop lib itself, the check was not enough as it didn't take into consideration that the page could have external onmousedown assigned.
To prove it quickly, you may take any orignal demo from www.walterzorn.com and add the following code to page:
<script>
document.onmousedown=function(){alert("you should see me once only.");}
</script>
Now you click on page - you'll see 2 alerts instead of 1 per click - due to the bug. If replacing the alert with a common event preservation logic, like the one used in calendarxp, you will end up with stack overflow because the 1st call sets up the correct preservation and the 2nd one created a recursion loop with no end.
_________________ Copyright 2003-2011 Idemfactor Solutions, Inc. All rights reserved. |
|