Using a bookmarklet to track a package

Posted by user307558 on Stack Overflow See other posts from Stack Overflow or by user307558
Published on 2010-04-02T09:02:00Z Indexed on 2010/04/02 9:03 UTC
Read the original article Hit count: 309

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about bookmarklet