Skip to content

Instantly share code, notes, and snippets.

@dungsaga
Created September 9, 2020 03:28
Show Gist options
  • Save dungsaga/45788260c81832de54ab5e237b523d22 to your computer and use it in GitHub Desktop.
Save dungsaga/45788260c81832de54ab5e237b523d22 to your computer and use it in GitHub Desktop.
JavaScript Bookmarklet in IE

Each bookmark is stored in a shortcut file under %USERPROFILE%/Favorites It looks like this:

[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,15
[InternetShortcut]
URL=javascript:alert('oh yea')
IDList=
[Bookmarklet]
ExtendedURL=javascript:alert('oh yea')

If the URL is short, only 2 lines are enough:

[InternetShortcut]
URL=javascript:alert('oh yea')

This shortcut file seems to be encoded in Windows default encoding (ANSI code page 1252). Don't try to put weird emoji in URL. But the URL can contain spaces. It's enough for embeded javascript. This shortcut file use format INI, so I guess the URL is terminated with a EOL separator.

IE11 in Windows 10 allows favorite to contain URL upto 5119 bytes (not characters). It's stored in ExtendedURL. URL contains a truncated string (maximum 2083 bytes) of ExtendedURL. The tooltip is further truncated (down to 255 bytes).

If you change ExtendedURL, but forget to update URL, then the bookmarklet won't work anymore.

Note that function alert can show long text message, except when alert dialog has a checkbox "Don't let this page create more messages".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment