需要链接才能在同一窗口中打开 [英] Need link to open in same window

查看:79
本文介绍了需要链接才能在同一窗口中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我已经使用javascript
编写了以下类型的代码以打开新窗口

printURL =" abcd.aspx;
ClientScript.RegisterStartupScript(this.GetType(),"newWindow",< script> window.open(""+ printURL +"'',``'',``top = 100,left = 300,menubar =否,工具栏=否,位置=否,可调整大小=否,高度= 600,宽度= 850,状态=否,滚动条=是,最大化=空,可调整大小= 0,标题栏=否'');</script> );


它的工作正常,当我单击窗口打开按钮"时,它是打开的.但是,当我最小化窗口并再次单击窗口打开按钮"时,在其他窗口中打开新窗口时,我想在同一窗口上打开新窗口,请提出建议.

等待答复.

Hi
i have write following type of code for open new window using javascript

printURL= "abcd.aspx";
ClientScript.RegisterStartupScript(this.GetType(), "newWindow", "<script>window.open(''" + printURL + "'', '''', ''top=100,left=300,menubar=no,toolbar=no,location=no,resizable=no,height=600,width=850,status=no,scrollbars=yes,maximize=null,resizable=0,titlebar=no'');</script>");


its working fine, its open when i am clicking on "window open button". but when i minimize the window and again click on "window open button" new window open in other window, i want to open new window on same window, please suggest me.

waiting for reply.

推荐答案

答案是-您不能...

这是因为您的父页面不知道您上一次单击时打开的新窗口.这些浏览器窗口的父实例和子实例之间没有连接.因此,每次单击链接时,它将创建一个新的浏览器实例,并因此每次都创建一个新窗口.
The answer is - You cannot...

This is because your parent page does not know about the new window opened on your previous click. There is no connection between these parent and child instances of the browser windows. So each time you click the link it will create a new instance of browser and as a result a new window everytime.


签出:
<html>
<head>
<script type="text/javascript">
var theWin = null;
function open_win(url)
{
    if(theWin && theWin.location)
        theWin.location.href=url;
    else
        theWin = window.open(url,"TheWin",'top=100,left=300,menubar=no,toolbar=no,location=no,resizable=no,height=600,width=850,status=no,scrollbars=yes,maximize=null,resizable=0,titlebar=no');
    theWin.focus();
}
</script>
</head>
<body>

<a href="#" onclick="open_win('http://google.com')" />google</a>
<a href="#" onclick="open_win('http://yahoo.com')" />yahoo</a>

</body>
</html>



注意:使用IE有一些限制(请参阅: http://msdn .microsoft.com/en-us/library/ie/ms536651(v = vs.85).aspx [



Note: with IE has some limitations (see: http://msdn.microsoft.com/en-us/library/ie/ms536651(v=vs.85).aspx[^])


我已经找到了解决方法

i have got the solution

function openWindow(printURL) {
             var newWin = window.open(printURL, 'PrintABC', 'top=100,left=300,menubar=no,toolbar=no,location=no,resizable=no,height=600,width=850,status=no,scrollbars=yes,maximize=null,resizable=0,titlebar=no');
             if (newWin != null) {
                 newWin.focus();
                 void (0);
             }
          }


这篇关于需要链接才能在同一窗口中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆