Mobile Safari Blocks Javascript in URL - Safari cannot run script because JavaScript cannot be used in this way

I studied how to create bookmarklets for use with mobile safari, and I ran into this problem:

I am not sure why I cannot find any questions on this topic. And my Google searches also had nothing. But it seems that iOS has completely banned the use of JavaScript in the address bar of a mobile safari. A message appears that looks like this:

Safari cannot run the script because JavaScript cannot be used in this way

They even got to the point that when you edit a bookmark on mobile Safari, there is no way to avoid single quotes or double quotes, and they completely disable double quotes from the keyboard - thus the handicap is the ability of the user to create a bookmark with these characters in it.

So, is there a way to make a bookmarklet that actually does something? For example, can I create a bookmarklet that allows me to link to a specific website using the selected text as a parameter in the URL?

And is it just me or is it something new?

+5
source share
1 answer

The bookmarklet solution in Safari mobile is simply not to use the address bar. Create a bookmark for some random site and subsequently edit it. I.e:.

  • Visit google.com or some other random site
  • Bookmark (using the sharing button)
  • Go to bookmarks and click edit
  • Select a bookmark bookmark and enter the code in the address field
  • Save changes

What is it. A bit uncomfortable, but it works.

+6
source

Source: https://habr.com/ru/post/1233740/


All Articles