我有 2 个单独的书签
javascript: (function () { var url = document.location; var links = document.getElementsByTagName('link'); var myvar = 'none'; for (var i = 0, l; l = links[i]; i++) { if (l.getAttribute('rel') == 'next') { myvar = l.getAttribute('href'); break; } } alert(myvar); })();
和
javascript: (function () { var url = document.location; var links = document.getElementsByTagName('link'); var myvar = 'none'; for (var i = 0, l; l = links[i]; i++) { if (l.getAttribute('rel') == 'prev') { myvar = l.getAttribute('href'); break; } } alert(myvar); })();
我想将它们组合成一个,以便两者都显示在一个书签中。我希望这会做到,但显然我塞满了
javascript: (function () { var url = document.location; var links = document.getElementsByTagName('link'); var myvar = 'none'; var myvar1 = 'none'; for (var i = 0, l; l = links[i]; i++) { if (l.getAttribute('rel') == 'next') { myvar = l.getAttribute('href'); break; } } { if (l.getAttribute('rel') == 'prev') { myvar1 = l.getAttribute('href'); break; } } alert(myvar + ' ' + myvar1); })();