gpt4 book ai didi

asp.net - facebox打开页面获取querystring

转载 作者:行者123 更新时间:2023-11-28 00:25:05 27 4
gpt4 key购买 nike

我在一个页面 mainpage.aspx"中,我有以下代码:
<a rel="facebox" href="destination.htm?path=blabla">mainpage</a>
我正在使用 facebox() 加载 destination.htm
问题出在我的 destination.htm 中,当我尝试发出警报(window.location.href)时,我得到的是 mainpage.aspx 而不是 destination.htm。为什么?我想要做的就是从页面读取路径以获取查询字符串(但我得到了错误的路径)。
非常感谢

最佳答案

那是因为 facebox 实际上并没有将浏览器重定向到该页面,而是通过 ajax 获取并将其注入(inject)到同一页面上的 facebox div 中。

您可以尝试获取 anchor 的 href 属性,也许是这样的:

var lastVisited = null;
var lastVisitedQS = null;
$("a[rel='facebox']").facebox()
.click(function() {
lastVisited = this.href;

// you can extract the query string like this
var a = document.createElement('a');
a.href = lastVisited;
lastVisitedQS = a.search; // should give path=blabla
});

然后在您的 destination.htm 中执行:

alert(lastVisited);
alert(lastVisitedQS);

希望对您有所帮助!

关于asp.net - facebox打开页面获取querystring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6439371/

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