Javascript 文本搜索和替换不适用于小书签
Javascript text search and replace don't work on bookmarklet
我用鼠标高亮了下面的文字:
Site: http://www.solidfiles.com
Sharecode[?]: /d/1234567890
然后使用以下书签命令:
javascript:(function(){
var txt = window.getSelection();
txt = txt.replace('[?]', '');
txt = txt.replace('Site: ', '');
txt = txt.replace('Sharecode: ', '');
txt = txt.replace(/\n/g, '');
window.open(txt);
})();
javascript 在使用 txt.replace 命令时停止工作。我不知道出了什么问题。请帮忙。
window.getSelection()
return a Selection object,之前需要先进行字符串化:
txt = txt.toString();
.
我用鼠标高亮了下面的文字:
Site: http://www.solidfiles.com
Sharecode[?]: /d/1234567890
然后使用以下书签命令:
javascript:(function(){
var txt = window.getSelection();
txt = txt.replace('[?]', '');
txt = txt.replace('Site: ', '');
txt = txt.replace('Sharecode: ', '');
txt = txt.replace(/\n/g, '');
window.open(txt);
})();
javascript 在使用 txt.replace 命令时停止工作。我不知道出了什么问题。请帮忙。
window.getSelection()
return a Selection object,之前需要先进行字符串化:
txt = txt.toString();
.