【发布时间】:2010-05-10 04:44:59
【问题描述】:
在 Google Analytics(分析)的某些页面上,URL 中显示了一个变量。默认值为 10。URL 始终如下所示:
...&trows=10&...
有没有办法将其更改为 trows=100,以便默认显示的行数为 100?
谢谢
【问题讨论】:
标签: javascript url greasemonkey
在 Google Analytics(分析)的某些页面上,URL 中显示了一个变量。默认值为 10。URL 始终如下所示:
...&trows=10&...
有没有办法将其更改为 trows=100,以便默认显示的行数为 100?
谢谢
【问题讨论】:
标签: javascript url greasemonkey
if (/[\?&]trows=10[^\d]/i.test(document.location.href))
document.location.replace(document.location.href.replace("trows=10","trows=100"));
使用document.location.replace() 使后退按钮仍然有效。
【讨论】:
location.replace(),您真的阅读过您指向的文档吗?
if (/trows=10(?!\d)/.test(location.href))
location.href=location.href.replace("trows=10","trows=100");
编辑:如果您想使用返回按钮返回到 trows=10 页面,请使用.assign 方法,而不是.replace,但由于您希望默认为 100,您可能不需要。
location.assign(location.href.replace("trows=10","trows=100"));
【讨论】:
trows=10 替换为trows=100,显然,他不需要回到trows=10 页面,所以确实如此没关系。
trows=10)然后你的代码启动并将他发送到 pg C,然后如果他点击后退按钮,他将转到 pg B,这将重定向他到 pg C,因此后退按钮不适用于您的代码(如果不回击两次,他就无法到达 pg A)。
是的。您可以修改页面链接,在 URL 中存在“错误”参数时重新加载页面(使用修改后的参数),或两者兼而有之。对于前者,XPath 对于查找链接非常有用(但不是必需的)。对于后者,可以修改window.location.search。
【讨论】: