私は、ユーザーが既に解析済みのページにいるかどうかを検出するブックマークレットを作成しようとしています。値がない場合、APIに渡す必要があります。そこJavascript Bookmarklet If-Else
if (window.location.indexOf("thequeue.org") >= 0) {
alert("Drag the Bookmarklet in your Brookmarks Bar!");
} else {
location.href = 'http://thequeue.org/r?id=' + encodeURIComponent(location.href) + '&title=' + document.title;
}
一般的なブックマークレットのいくつかのチュートリアルがありますが、私は、この変換ツールを発見した:http://jasonmillerdesign.com/Free_Stuff/Instant_Bookmarklet_Converter、私はこれを与えた:ブックマークレットが完全に動作を停止しかし
javascript:(function(){if(window.location.indexOf(%22queue.org%22)%20%3E%3D%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20alert(%22your%20url%20contains%20the%20name%20franky%22)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%20else%20%7B%0Alocation.href%3D'http%3A%2F%2Fthequeue.org%2Fr%3Fid%3D'%2BencodeURIComponent(location.href)%2B'%26title%3D'%2Bdocument.title%3B%0A%7D}());
。これが動作することを確認できます:javascript:location.href='http://thequeue.org/r?id='+encodeURIComponent(location.href)+'&title='+document.title;
私は間違っていますか?
ありがとう、よかった!二重引用符を一重引用符に変更するだけでした。 – mmackh