使用小书签来跟踪包裹
我正在尝试编写一个小书签来跟踪邮件中的包裹。首先,它检查跟踪页面是否打开,如果没有打开,则在新选项卡中打开它,然后将表单的值设置为跟踪号码。最后,它提交表单。到目前为止,我无法做的是在书签打开新选项卡的情况下设置表单的值。
这是我所拥有的:
javascript: (函数(){
vartrackingNumber = "/*追踪号码*
/";
var a = document.forms.trackingForm;
if ('http://fedex.com/Tracking' == document.location) {
trackingForm.trackNbrs.value=trackingNumber;
document.forms.trackingForm.submit();
}
否则{
window.open('http://fedex.com/Tracking');
this.window.onload = function(){
//这似乎是问题
trackingForm.trackNbrs.value=trackingNumber;
onload(document.forms.trackingForm.submit());
}
}
})();
有什么想法吗?
I'm trying to write a bookmarklet that tracks a package in the mail. First it checks to see if the tracking page is open, if not it opens it in a new tab, and then sets the value of the form to the tracking number. Finally, it submits the form. What I'm so far unable to do is set the value of the form in the case where the bookmarklet opens up a new tab.
Here's what I have:
javascript: (function(){
var trackingNumber = "/*tracking number*
/";
var a = document.forms.trackingForm;
if ('http://fedex.com/Tracking' == document.location) {
trackingForm.trackNbrs.value = trackingNumber;
document.forms.trackingForm.submit();
}
else {
window.open('http://fedex.com/Tracking');
this.window.onload = function(){
//This seems to be the problem
trackingForm.trackNbrs.value = trackingNumber;
onload(document.forms.trackingForm.submit());
}
}
})();
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
window.open
打开一个新窗口,因此如果这完全可以工作(我对书签没有什么经验),您将必须直接处理新窗口。像这样的东西:window.open
opens a new window, so if this is going to work at all (I have little experience with bookmarklets), you would have to address the new window directly. Something like this: