如何在每个特定间隔“Javascript”中用零递增 url?
我想使用 javascript 自动增加一个 url,并在“Firefox”上的 Greasemonky 中使用它
,例如:
www.google.com/id=1
www.google.com/id=01
www.google.com/id=001
www.google.com/id=0001
如何使用 javascript 实现这一点???
这是我写的
var numberr = “2”;
var totall = “”;
var timeout = 12000;
setTimeout(function() {
var numm = “0” + numberr;
totall = “http://www.google.com/id=0” + numm;
window.location.href = totall;
}, timeout);
,但我没有按预期增加零,
有人可以帮助我吗?
我不知道是什么问题,也许是油猴的问题? 我不知道
- - - - - - - - - - - - - - - - - - - - - - - ------------------
好的,这似乎是一个 javascript 无法修复的问题,所以我将使用 C# 在 Windows 应用程序中实现逻辑,但我需要知道如何访问 [[firefox]] url ,并在 Windows 应用程序中通过 C# 重新加载操作,有人可以帮忙吗???
I want to increment a url automatically using javascript and use it in Greasemonky on "Firefox"
ex:
www.google.com/id=1
www.google.com/id=01
www.google.com/id=001
www.google.com/id=0001
how can I achieve that using javascript???
here is what I wrote
var numberr = “2”;
var totall = “”;
var timeout = 12000;
setTimeout(function() {
var numm = “0” + numberr;
totall = “http://www.google.com/id=0” + numm;
window.location.href = totall;
}, timeout);
but i doesn't increment the zeros as i expected,
can anybody help me?
I don't know what is the problem, maybe it is the Greasemonkey?? I don't know
---------------------------------------------------------------
OK, It seems to be a javascript unfixable problem, So I'll implement the logic in a Windows application using C#, BUT I neet to know how to access [[firefox]] url , and reload action through C# in a windows application, can anybody help?????
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的变量值不会在页面加载之间持续存在,因此每次都会重置计数器。 不过,有一个解决方案!
http://diveintogreasemonkey.org/advanced/gm_getvalue.html
或者,您可以解析当前用于确定您在循环中的位置的 URL。 尝试这个:
Your variable values won't persist between page loads, thus resetting the counter each time. There is a solution, however!
http://diveintogreasemonkey.org/advanced/gm_getvalue.html
Alternatively, you can parse the current URL to determine your location within the loop. Try this:
你想出什么数字? 看起来您总是会比您的描述指示多添加一个 0,因为根据
这些行的外观,您会自动添加一个 0,即使您从“2”开始,您的第一个请求也将被
编辑:并且另一件事,您需要在函数调用结束时将 numm 分配给 numberrr 。 这是您想要实现的目标吗?
再次编辑:是的,Zed 所说的,一旦您更改页面位置,一切都会重置。
What number are you coming up with? it looks like you are always going to be adding one more 0 than your description indicates since you are automatically adding one 0 with
by the look of those lines, even if you start out with "2", your first request will be
edit: and another thing, you are going to need to assign numm to numberrr at the end of the function call. Is this what you are trying to achieve?
edit again: ya, what Zed says, once you change your page location everything will reset anyways.
尝试这个:
try this: