gpt4 book ai didi

javascript - Window.Open() 正在更改 Internet Explorer 上的页面布局

转载 作者:可可西里 更新时间:2023-11-01 13:12:35 25 4
gpt4 key购买 nike

我在 asp.net 中有一个名为 Home.aspx 的页面。它使用母版页,还有一个调用的按钮:

Response.Write("<script> window.open('page2.aspx','_blank'); </script>")

结果:新选项卡打开page2.aspx,如果返回Home.aspx,页面布局被修改,中央<div>移至页面左侧。

我该怎么做才能解决这个问题?请记住,这只发生在 Internet Explorer 上,Firefox 正常工作!

非常感谢。

最佳答案

不去探究你为什么这样做的优点,你的 Response.Write 可能会杀死 Home.aspx 页面中的 HTML/CSS/JS 输出并阻止它正确加载。尝试使用:

ScriptManager.RegisterStartupScript(typeof(Page),
"OpenPage2", "window.open('page2.aspx','_blank');", true);

而不是 Response.Write,因此一旦页面加载,它就会打开您的窗口。

关于javascript - Window.Open() 正在更改 Internet Explorer 上的页面布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18111089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com