当我在书签栏中点击它时,为什么这个书签不起作用?

问题描述 投票:0回答:1

我想制作一个书签,将当前的YouTube网址更改为listenonrepeat.com上的等效网址,以便重复播放视频。我的书签栏中有一个带有以下javascript的书签:

javascript:window.location=window.location.href.replace("youtube","listenonrepeat");

但是除非我将其复制并粘贴到URL栏中,否则它不会改变它。 Safari 6。

在这里可以看到:http://christianselig.com/youtubefix.html

javascript bookmarklet
1个回答
0
投票

替换url并将其嵌入到函数中,如下面的代码,使它直接在listenonrepeat中打开一个新窗口:

javascript:(function(win){win.open(win.location.href.replace("youtube","listenonrepeat"));})(window)
© www.soinside.com 2019 - 2024. All rights reserved.