在IE6底下,我们加上<base target="_self"/>
一般就可以实现在本窗口中提交,点击页面上的link也会在本窗口跳转。
但是在用IE7的情况,还是会打开一个新页面。
请教一下这时候该如何处理。

解决方案 »

  1.   

    JKHtml里有对这个问题进行讨论处理:
    JKHtml\问题收集(csdn)\Dialog里弹出新窗口的解决\test.htm
    下载地址
    http://download.csdn.net/source/276201test.htm:<html> 
    <head> 
    <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312"> 
    <title> JK:支持民族工业,尽量少买X货 </title> 
    <script   language=javascript   srcccccc="CommonJSFunction.js"> 
    /** 
    *   This   function   is   to   submit   a   form   to   ModalDialog. 
    *   JK   2007-03-06 
    */ 
    function   submitToModalDialog(formObj,dialogTitle,sFeatures){ 
    var   dialogArguments=new   Array(); 
    dialogArguments["src"]=null; 
    dialogArguments["title"]=dialogTitle; 
    dialogArguments["form"]=formObj; 
    return   showModalDialog("DialogFrame.htm",dialogArguments,sFeatures); 

    </script> 
    </head> 
    <body> 
    <form   name="frm0"   action="test.htm" > 
    <input   type=button   value=DialogFrame   onclick="var   a=new   
    Array();a['src']='test.htm';window.showModalDialog('DialogFrame.htm',a);"/> <br/> 
    <input   name=q> <input   type=button   value=DialogFrame   onclick="submitToModalDialog(this.form,'JK','');"/> <br/> 
    <a href="http://jkisjk.spaces.live.com">http://jkisjk.spaces.live.com</a> <br/> 
    </form> 
    <hr/> 
    </body> 
    </html> ---------------------------- DialogFrame.htm
    本页面解决的问题
    1。IE设置检查更新为"自动"时dialog里的信息是旧数据
    2。dialog里location.href=url导致新开窗口 (另外一个解决办法是dialog里的所有页面加<base target="_self"/>)
    3。支持submitToModalDialog<html> 
    <head> 
    <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312"> 
    <script   language=javascript> 
    var   DialogArgument=window.dialogArguments; 
    //The   following   code   exists   for   :IE   6   can   not   change   dialog   title. 
    if   (DialogArgument && DialogArgument.title)   document.write(" <title>"+DialogArgument.title+" </title>"); 
    else   document.write(" <title> Dialog </title>"); 
    </script> 
    </head> 
    <body   leftMargin=0   rightMargin=0   topMargin=0   bottomMargin=0   onload="initFun();"   scroll=no>
    <iframe   name="dialogFrame"   src="blank.html"   width=100%   height=100%   id=dialogIframe> </iframe> 
    <form   name="dialogForm"   method="post"   action=""   target="dialogFrame"   style="display:onne;"> 
    </form> 
    </body> 
    </html> 
    <script   language=javascript> 
    function   initFun() 

    if   (DialogArgument!=null){ 
    if(DialogArgument.form!=null){ 
    var   argForm=DialogArgument.form; 
    var   tempForm=document.dialogForm; 
    tempForm.action=argForm.action; 
    var   argFormElements=argForm.elements; 
    for(var   i=0;i <argFormElements.length;i++){ 
    tempForm.insertAdjacentHTML("beforeEnd",argFormElements[i].outerHTML); 

    tempForm.submit(); 

    else{ 
    document.dialogForm.action=DialogArgument.src; 
    document.dialogForm.submit(); 


    else   alert("useDialogFrameWrongly"); 

    </script>