bookmarklet

Does execCommand SaveAs work in Firefox?

China☆狼群 提交于 2019-11-26 05:37:55
问题 Why does this not work in ff/chrome? javascript: document.execCommand(\'SaveAs\',\'true\',\'http://www.google.com\'); (used as a bookmarklet) 回答1: execCommand is not completely standardized across browsers. Indeed, execCommand('SaveAs', ...) only seems to be supported on IE. The recommended way to force a save-as would be to use a content-disposition: attachment header, as described in http://www.jtricks.com/bits/content_disposition.html Since this is part of the HTTP header, you can use it

Change CSS of selected text using Javascript

痞子三分冷 提交于 2019-11-26 03:41:56
问题 I\'m trying to make a javascript bookmarklet that will act as a highlighter, changing the background of selected text on a webpage to yellow when the bookmarklet is pressed. I\'m using the following code to get the selected text, and it works fine, returning the correct string function getSelText() { var SelText = \'\'; if (window.getSelection) { SelText = window.getSelection(); } else if (document.getSelection) { SelText = document.getSelection(); } else if (document.selection) { SelText =