Right, I figured out what is wrong with the bookmark, and it's down to URL quoting, see below.
> You can verify javascript: is currently working otherwise by doing javascript:alert()
The bookmark editor in FF iOS does not actually let you create such a bookmark, so testing was hampered (create a new bookmark, and you'll be given a URL-specific keyboard and URLs that start with `javascript:` are not accepted as the *Save* action remains disabled). I had previously used an existing JS bookmark that indeed uses quotes but was created on the desktop. A plain `javascript:alert()` bookmark created on the desktop then synched to iOS indeed works.
The following bookmark is opened as a search, however:
```js
javascript:(function(){var a=Array.from(document.querySelectorAll("a[href$='.jpg']"), l => l.getAttribute('href'));a.sort();for(var i=0;i<a.length;i++){window.open(a[i]);}})()
```
This bookmark is designed to find all JPEG links and opens these in separate tabs (warning: popup blockers won't like this one, especially when there are many such images). The bookmark works fine on the desktop, is synched to iOS, then fails to work as expected on FF.
I traced this to URL quoting; the above uses spaces and plenty of non-URL-safe characters. Here is the quoted version:
```html
javascript:%28function%28%29%7Bvar%20a%3DArray.from%28document.querySelectorAll%28%22a%5Bhref%24%3D%27.jpg%27%5D%22%29%2C%20l%20%3D%3E%20l.getAttribute%28%27href%27%29%29%3Ba.sort%28%29%3Bfor%28var%20i%3D0%3Bi%3Ca.length%3Bi%2B%2B%29%7Bwindow.open%28a%5Bi%5D%29%3B%7D%7D%29%28%29
```
That one does work properly.
I appreciate the difference, I forgot entirely that *as a URL* you need to quote the non-URL-safe characters. Clearly, desktop FF doesn't care and handles quoting for us. The unexpected behaviour on iOS in this case is more that it is treated as a search, instead.
Should this be treated as a bug, and if so, should this be a separate, new ticket? Should the desktop behaviour be how iOS FF handles such bookmarks?
Bug 1296636 Comment 14 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
Right, I figured out what is wrong with the bookmark, and it's down to URL quoting, see below.
> You can verify javascript: is currently working otherwise by doing javascript:alert()
The bookmark editor in FF iOS does not actually let you create such a bookmark, so testing was hampered (create a new bookmark, and you'll be given a URL-specific keyboard and URLs that start with `javascript:` are not accepted as the *Save* action remains disabled). I had previously used an existing JS bookmark that indeed uses quotes but was created on the desktop. A plain `javascript:alert()` bookmark created on the desktop then synched to iOS indeed works.
The following bookmark is opened as a search, however:
```js
javascript:(function(){var a=Array.from(document.querySelectorAll("a[href$='.jpg']"), l => l.getAttribute('href'));a.sort();for(var i=0;i<a.length;i++){window.open(a[i]);}})()
```
This bookmark is designed to find all JPEG links and opens these in separate tabs (warning: popup blockers won't like this one, especially when there are many such images). The bookmark works fine on the desktop, is synched to iOS, then fails to work as expected on iOS FF.
I traced this to URL quoting; the above uses spaces and plenty of non-URL-safe characters. Here is the quoted version:
```html
javascript:%28function%28%29%7Bvar%20a%3DArray.from%28document.querySelectorAll%28%22a%5Bhref%24%3D%27.jpg%27%5D%22%29%2C%20l%20%3D%3E%20l.getAttribute%28%27href%27%29%29%3Ba.sort%28%29%3Bfor%28var%20i%3D0%3Bi%3Ca.length%3Bi%2B%2B%29%7Bwindow.open%28a%5Bi%5D%29%3B%7D%7D%29%28%29
```
That one does work properly.
I appreciate the difference, I forgot entirely that *as a URL* you need to quote the non-URL-safe characters. Clearly, desktop FF doesn't care and handles quoting for us. The unexpected behaviour on iOS in this case is more that it is treated as a search, instead.
Should this be treated as a bug, and if so, should this be a separate, new ticket? Should the desktop behaviour be how iOS FF handles such bookmarks?