日期:2014-05-16  浏览次数:20380 次

请教:在使用frameset框架的web页面中如何实现关闭ie弹出确认对话框后点击确认跳转到另外一个页面否则还停留在当前页面
在使用frameset框架的web页面中如何实现关闭ie弹出确认对话框后点击确认跳转到另外一个页面否则还停留在当前页面

我的代码如下:

 <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>  
  function window_onbeforeunload() {  
 if(confirm('您真的要退出吗?')){ 
 top.window.close();  
  window.location.href="logout.jsp";  
  }
 
  }  
  </SCRIPT> 

<frameset rows="85,*" framespacing="0" frameborder="1" border="false" scrolling="yes" onbeforeunload="return window_onbeforeunload()">
  <frame name="top" scrolling="no" src="index_Top.jsp">
  <frameset framespacing="0" border="false" cols="153,10,*" frameborder="0" id="frame" scrolling="yes">
  <frame name="left" scrolling="auto" marginwidth="0" marginheight="0" src="index_Left.jsp"> 
<frame name="center" scrolling="no" src="index_Center.jsp" noresize>
  <frame name="main" scrolling="auto" src="index_Main.jsp" noresize>
  </frameset>
</frameset>

当弹出确认对话框时候 点 ‘取消’ 的时候还是关闭了页面。
请教诸位在含有框架的页面中硬挨如何写?
在线等待!!!

------解决方案--------------------
要结合onunload事件来执行.

onbeforeunload事件是返回一个信息,有浏览器控制你是刷新或者干什么,onunload事件是页面卸载时发生,onbeforeunload产生的信息返回是否执行onunload或者不执行

JScript code
//注意写法,不是window_onbeforeunload,不过这样只有ie能支持,要ff也支持的话另写一个事件函数
function  window.onbeforeunload{){           
  event.returnValue='您真的要退出吗?'
}          
function window.onunload()//注意写法,不是window_onunload
{
  top.window.close();     
  window.location.href="logout.jsp";
}