开发者

bookmarklet location.href on about:blank

I've created a bookmarklet as follows:

// Assuming a keyword of 'pin',
//   'pin' will retrieve all bookmarks
//   'pin linux' will retrieve all bookmarks tagged 'linux'
//   'pin linux tools' will retrieve all bookmarks tagged both 'linux' and 'tools'
javascript:params='%s';url='http://pinboard.in/u:xiong.chiamiov';if(params!=''){tags=params.split('%20');for(i=0;i<tags.length;i++){url+='/t:'+tags[i];}}location.href=url;

This works as intended on existing pages. However, when a page doesn't 开发者_StackOverflow社区actually exist in the current tab (for instance, about:blank), I get nothing, presumably because document.location doesn't yet exist. open(url) does not work, either.

Is there another way to make this work? I'm using Firefox, if it matters.


You code works on my Firefox - page redirect from about:blank to your webpage(http://pinboard.in/u:xiong.chiamiov/t:%s).

I test document.location from a about:blank page, it works too, please try:

  1. Open a about:blank page in Firefox
  2. run javascript:alert(document.location.href);void(0)

*i think you'd better add void(0) at the end on your code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜