`

showModel的使用体会

阅读更多

1.
        <base target="_self" />在IE7中无效的解决办法
通过ShowModalDialog 打开页面,在POSTBACK时,打开新的页面,
在IE6下没问题,只有在IE7下,会重新打开一新页面,

其实只要把<base target="_self"/>放到<head>下即可。
<head>
<base target="_self"/>
。。。。

而在IE6中位置没有限制。一定要求是放在<head>下面
关键字: _self, <base target=/> ie6.0 ie7.0
最近项目中一个小问题卡了我不少时间。我遇到的问题是:在项目的弹出式的模型窗口里,我需要将数据提交到服务器。然后从服务器再返回到本页面。结果:返回了本页面,窗口却是从新打开的。
  现在来谈一下解决方法:书上说在模型窗口中加入<base target="_self"/>标签即可。我把该标签放上去却没有任何反应,当时我不明白这为什么?后来经过查证原来这个属性有IE6与IE7之分。忘了说我的浏览器是IE7的。
注:
1、如果你是IE6,你将<base target="_self"/>加入到<head>标签里就可以了。
2、如果你是IE7,你必须将<base target="_self"/>加入到<head>的对口中位置。
代码示例:
<html>
<head>
<title>test</title>
<base target="_self"/>
.............
</head>
</html>
target 属性 -- 代表链接目标
取值
_blank -- 打开一个新窗体
_parent -- 在父窗体中打开
_self -- 在本页打开,此为默认值
_top -- 在上层窗体中打开
一个对应的框架页的名称 -- 在对应框架页中打开
此标记已经被w3c抛弃


showModel的调用
父页面代码:
     var ts = window.showModalDialog("<%=path%>"+"/adv/AdvRegisterAction.do?act=advList&cusName="+cusName+"&time="+new Date(),window,"dialogWidth:650px;dialogHeight:450px;center:yes;help:no;status:no;resizable:no");
     theForm.elements("registerDto.ads.cusId").value=ts[0];        //ts为返回值
     theForm.elements("registerDto.ads.contId").value=ts[1];
     theForm.elements("registerDto.ads.cusName").value=ts[2];

   打开的页面:
        function select(conId,cusId,cusName){
                    var ts = new Array();
                    ts[0]=cusId;
                    ts[1]=conId;
                    ts[2]=cusName;
                    window.returnValue = ts;
        window.close();
    }

  这样既可以再父主页面之间传递数据,不过这种形式在IE7.0中存在问题。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics