gpt4 book ai didi

javascript - 更新面板删除了 URL 片段

转载 作者:行者123 更新时间:2023-11-30 06:47:17 25 4
gpt4 key购买 nike

我的问题:

我用IE8来测试。

我创建了一个简单的 aspx 页面 (mypage.aspx),其中包含一个带有按钮 (button1) 的更新面板。加载页面时,我使用 javascript 将片段添加到 window.location

window.location.href = window.location.href + "#myfragment";
//Window address bar will be: http://mydomain.com/mypage.aspx#myfragment

然后我点击button1,我的页面更新成功。但是在地址栏中 myfragment 被删除了

//Window address bar will be: http://mydomain.com/mypage.aspx#

我的问题:

发生了什么事?单击 button1 时如何保留 myfragment?

注意:此问题仅在IE8下出现,Firefox和google chrome均正常。

感谢任何回答...

最佳答案

当您进行回发时,服务器会完全重建页面。除非您确保用户输入的页面的任何元素都保持在 View 状态,否则回发页面时返回的数据中不会携带用户输入的信息

http://msdn.microsoft.com/en-us/library/ms178472.aspx - 页面生命周期

http://msdn.microsoft.com/en-us/library/ms972976.aspx - 查看状态

会有所帮助 - 这是一个学习曲线 - 但可能非常值得

关于javascript - 更新面板删除了 URL 片段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5296730/

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