【问题标题】:Restore Window Size on Redirect from PopUp从弹出窗口重定向时恢复窗口大小
【发布时间】:2020-03-19 22:33:36
【问题描述】:

这可能有一个简单的解决方案,但我不知道它是什么。我有一个弹出窗口,我在其中执行标准 Response.Redirect 到新页面,基于单选按钮选择。一切都按预期工作,但新页面与弹出窗口大小相同(因为它出现在同一个弹出窗口中)。如何让新页面显示为普通页面而不是弹出窗口?


function EditOrder(f) {

var orderid_values = document.getElementsByName('OrderIDValues');
var orderid_value;

    for(var i = 0; i < orderid_values.length; i++){
        if(orderid_values[i].checked){
        orderid_value = orderid_values[i].value;
        }
    }

    window.open("/memberlogin/orders/editorderpopup.asp?cert=<%=sCertificate%>&loginid=<%=iSessID%>&cid=<%=iCustomerID%>&oid=" + orderid_value,"dialogCancelOrder","resizable=0,scrollbars=yes,location=yes,toolbar=no,status=no,top=200,left=500,width=900,height=900")

} 
</script> 

然后,在 EDITORDERPOPUP.ASP 页面中,基于所选单选按钮发生以下重定向(这只是页面外的一个 sn-p):

' Based upon the radio button value (1,2,3.., etc.), call the EDITORDER.ASP page with the "editmode" = to the same value:

sURL = sRootDomain & "/administration/manualordering/editorder.asp?cert=" & sCertificate & "&loginID=" & iSessID & "&EditMode=" & RadioButtonValue

然后新页面将显示在弹出窗口中。我希望新页面是一个全新的窗口,或者是一个完整的窗口。

【问题讨论】:

  • 您介意与我们分享一些代码吗?
  • 绝对!我只是不认为在这种情况下需要代码。我想这就是为什么有人给了我一个否定的 1。我会立即解决这个问题。
  • 您可能想要添加一些预期的行为,例如,如果您希望弹出窗口在您被重定向后仍然存在,或者您希望窗口关闭。或者,如果您希望将弹出窗口调整为“正常”大小,然后在该窗口中打开它。您必须记住,浏览器会记住您的窗口大小历史记录,因此如果您希望它以特定的高度和宽度打开,您可能需要告诉新窗口调整大小。
  • @DanielNordh 感谢您的回复。我相信你所说的完全正确,那就是“你可能想要添加一些预期的行为......”事实上,在重定向之后,我不想再弹出存在了。这是怎么做到的?

标签: javascript redirect asp-classic popup


【解决方案1】:

Response.Redirect 将始终出现在同一个窗口/选项卡中,因此要重定向到另一个窗口/选项卡,您应该使用 client 而不是 server 脚本。

例子:

使用客户端&lt;script&gt;打开弹出窗口的母版页

<button onclick="popup()">Open popup</button> 
<script> 
    function popup() {
        window.open('popup.asp', '', 'height=400,width=400');
    }
</script>

除了客户端&lt;script&gt;之外什么都没有的popup.asp

<input type="radio" id="a" name="r1" onclick="win1()" />
<input type="radio" id="b" name="r1" onclick="win2()" />

<script>
    function win1() {
        window.open('https://stackoverflow.com');
    }
    function win2() {
        window.open('https://microsoft.com');
    }
</script>

【讨论】:

  • 你好,亚历克斯。谢谢你的文章。我认为您在这里所说的是不使用 Response.Redirect,而是使用 Javascript 进行页面重定向。我会尽快尝试并回来更新。谢谢!
猜你喜欢
  • 1970-01-01
  • 2016-02-08
  • 2019-03-18
  • 1970-01-01
  • 2018-04-03
  • 2011-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多