Skip to main content
The 2024 Developer Survey results are live! See the results
12 events
when toggle format what by license comment
Mar 14, 2022 at 7:58 history edited Joachim Lous CC BY-SA 4.0
clarify comments in code
Jan 5, 2021 at 23:00 comment added Kevin Fegan @netawater - I'm pretty sure that JoachimLous just meant that you should be careful if your bookmarklet code opens any alerts or "Popups" (like: window.alert("sometext");, alert("sometext");, window.confirm("sometext");, confirm("sometext");, window.prompt("sometext","defaultText"); or prompt("sometext","defaultText");), Before your code that writes to the clipboard. If you don't use alerts or prompts, or if you use them After your code that writes to the clipboard, you don't (shouldn't) have to worry about restoring the focus, you can ignore the ....focus(); stuff.
Dec 26, 2020 at 7:34 comment added netawater it works for firefox which doesn't support document.execCommand("copy") , but how it lost focus. what is the meaning do popup stuff? do you have a full example to copy webpage title to clipboard without lost focus. @JoachimLous
Oct 31, 2020 at 11:18 comment added Joachim Lous @kevin-fegan Bookmarklets need to return something falsy, unless you want the browser to replace the current page with the return value. This particular code already does, but it is standard practice to always explicitly null the return value so you are safe from any changes triggering that trap. There are many ways to ensure this - I prefer returning an explicit null or false.
S Oct 31, 2020 at 11:06 history suggested CommunityBot CC BY-SA 4.0
linebreak-safe comments, as suggested in comments
Oct 31, 2020 at 10:58 review Suggested edits
S Oct 31, 2020 at 11:06
Oct 24, 2020 at 0:20 comment added Kevin Fegan Also, since this is for a bookmarklet, everything is "compressed" (joined) to one line, so using // in a bookmarklet is a problem. I think /* comment */ should work fine.
Oct 24, 2020 at 0:16 comment added Kevin Fegan What is the purpose of null; in ;null; ?
May 20, 2020 at 19:21 comment added dotbit 'some text from somewhere' is so much more serious that the otherwise usual "bla blah bal" which would be used in an example.
Dec 6, 2019 at 11:48 history edited Joachim Lous CC BY-SA 4.0
declare variable
Dec 5, 2019 at 13:26 history edited Joachim Lous CC BY-SA 4.0
clarify that solution is only tested in chrome
Dec 5, 2019 at 13:19 history answered Joachim Lous CC BY-SA 4.0