我有一个名为makeIframeModal.js的js文件。通常,当我尝试创建iframe时,请使用jsp中的iframe标记,如下所示:
<iframe id="myIframeId" style="display:none;" height="430" width="675" src="myjsp.jsp" ></iframe>
现在makeIframeModal.js包含iframe描述,如下所示:
iframemodal = new modal($('framebtn'), {
afterOpen : function(){$$('.close a').invoke('observe','click',function(e){modal.close(); Event.stop(e);});},
opacity: 0.3,
width: 675,
fade: true,
fadeDuration: 0.1,
autoOpenIfLinked: false
});
所以,我的iframe在弹出窗口中打开。现在我在这个iframe中有一个链接,点击后会关闭iframe。我这样做:
function closeMyIframe()
{
var parentDynamicDiv = window.parent.document.getElementById('dynamic_id1');
var iframe = window.parent.document.getElementById('dynamic_id2');
iframe.style.display = 'none';
parentDynamicDiv.style.display = 'none';
}
但是,现在我需要打开另一个名为myNewIframeModal的iframe。
所以简而言之:当我关闭第一个iframe时,另一个iframe必须在弹出窗口中自动打开。怎么能实现我的这个功能?请帮助我。
答案 0 :(得分:0)
你可以在closeMyframe ...
中调用新模态function closeMyIframe()
{
var parentDynamicDiv = window.parent.document.getElementById('dynamic_id1');
var iframe = window.parent.document.getElementById('dynamic_id2');
iframe.style.display = 'none';
parentDynamicDiv.style.display = 'none';
iframemodal2 = new modal($('framebtn'), {
afterOpen : function(){$$('.close a').invoke('observe','click',function(e){modal.close(); Event.stop(e);});},
opacity: 0.3,
width: 675,
fade: true,
fadeDuration: 0.1,
autoOpenIfLinked: false
});
}