Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javascript: ban disallows legitimate use for bookmarklets #165

Open
Janiczek opened this issue Feb 20, 2020 · 4 comments
Open

javascript: ban disallows legitimate use for bookmarklets #165

Janiczek opened this issue Feb 20, 2020 · 4 comments

Comments

@Janiczek
Copy link

See Janiczek/ellies#3

I want to create a bookmarklet, which means an <a href="javascript:...">link</a> that I can drag to my bookmarks tab and there click on it to perform some JS on any page I'm on.

Elm's VDOM disallows this so the best I could do is to link to a file on GitHub that contains the bookmark source code.

@jackwilsdon
Copy link

jackwilsdon commented Feb 21, 2020

It's still possible to have a javascript: link using Html.Attributes.property, although this seems like more of a workaround than a solution:

module Main exposing (main)

import Html exposing (Html, a, text)
import Html.Attributes exposing (property)
import Json.Encode as E


main : Html msg
main =
    a [ property "href" (E.string "javascript:alert(\"This works!\")") ] [ text "Click me" ]

Ellie link

@Janiczek
Copy link
Author

Janiczek commented May 5, 2022

Note this workaround doesn't work with --optimize builds.

@laurentpayot
Copy link

Note this workaround doesn't work with --optimize builds.

Unfortunately this is true and makes this nice workaround useless 😞

@Janiczek
Copy link
Author

virtual-dom has recently been fixed; this now doesn't work in non-optimized builds either.

Here is a way to have bookmarklets in Elm via WebComponents: https://ellie-app.com/hwbBHmqLQ8Ra1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants