Upon click on the menu, I am creating an Iframe dynamically which points to another page in the same domain [same web application] which also contains infragistics datagid [non hierarchical] populated with default data retrieved from Data Base. After creating the frame I am attaching it to the HTML DOM [Div Layer] and show it as modal popup with OK and Cancel Button inside an ModalPopUpControl Extender. Upon click on any of the buttons, I am destroying the Iframe from DOM. I am calling ModalPopUpControl show() and hide() methods for displaying and canceling modal popup.
Following are the functions I am using for Iframe Creation and Destroy.
Expand|Select|Wrap|Line Numbers
- //----------------------------------------------------------------------------------------------------
- // oSrcCtrl – Parent Control where dynamic iframe to be attached (DIV)
- // strFraId - Iframe Identifier
- //-----------------------------------------------------------------------------------------------------
- function CreateIFrame(oSrcCtrl,strFraId) {
- var iframe = document.createElement("iframe");
- iframe.setAttribute("id", strFraId);
- iframe.setAttribute("scrolling", "no");
- iframe.setAttribute("frameBorder", "0");
- oSrcCtrl.appendChild(iframe);
- }
- //--------------------------------------------------------------------------------------------------------
- // oSrcCtrl – Parent Control where dynamic iframe to be attached (DIV)
- // strFraId - Iframe Identifier
- //---------------------------------------------------------------------------------------------------------
- function DestroyIframeById(oSrcCtrl, strFraId)
- {
- if (document.all)
- {
- document.getElementById(strFraId).src = 'javascript:false';
- document.all[strFraId].outerHTML = '';
- }else{
- oSrcCtrl.removeChild(document.getElementById(strFraId));
- }
- }
I would need your help to validate my JavaScript codes for Iframe creation and Remove. Also request you guys to suggest some alternate solutions to get away this memory leak.
I Just downloaded Javascript Memory leak detector from http://blogs.msdn.com/gpde/pages/jav...-detector.aspx and yet to profile my code, once i am done with that I'll update this post with my results and in the mean time i would appreciate any help. Showing and Hiding ModalPopUpControl using javascript code (behaviour.show() & behaviour.hide()) will casue any memory leak?
Note:
1. The response time to load the iframe is not an issue; it loads with in the expected time
2. For each Iframe request the response size is nearly 500KB [includes data retrieved from database + infragistics JavaScript resource files]