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:
- Open a about:blank page in Firefox
- run javascript:alert(document.location.href);void(0)
*i think you'd better add void(0) at the end on your code.
精彩评论