I can run JavaScript from mobile bookmarks
P粉949190972
2023-09-03 16:06:54
<p>I basically have no idea how to run JavaScript or how it works in bookmarks. I only see pages about how it's supposed to work but I can't figure it out! ! 1</p>
<p>Can I run JavaScript from bookmarks on my phone? </p><p>
I'm using Android and Chrome apps. I edited my bookmarks and added the example I found online, but I don't see it doing anything. </p>
<p>If possible, can someone<em><strong>post something I can copy/paste directly into a Chrome bookmark</strong></em> and see it perform something like< code>hello world operation</code>? </p>
<p>I tried <code>javascript:(alert("hello world");)</code> and <code>javascript:(function(){alert("hello world");}) </code> </p>
<p>I looked at these links but couldn't figure it out: </p><p>
https://en.m.wikipedia.org/wiki/Bookmarklet
https://stackoverflow.com/a/18872722/5582694</p>
<p>What did I do wrong? ? ? </p>
I thought we can't use bookmarks on mobile devices, but after this question, I did a little research and here are the results:
We can set a bookmark on Chrome and then use it on our phone, we can do this:
On desktop browsers, right-click the bookmarks bar and select Add Page or Add Bookmark from the menu. In the Name field, enter a name for the bookmarklet. In the URL field, enter the following code:
(This is just a test code, in the function you can write your own code)
Now in your mobile browser, open a page and type your bookmark name in that page (with an asterisk next to it) and click on it to view the alert test. Here are the results on desktop and mobile: