gorilla-repl icon indicating copy to clipboard operation
gorilla-repl copied to clipboard

hrefs don't navigate

Open sashton opened this issue 9 years ago • 3 comments

I've tried adding an href to HtmlView output. The link renders, but on clicking it, the browser doesn't navigate. Is there some global click handler which is preventing it?

Example:

#gorilla_repl.html.HtmlView{:content ("<a href=\"http://www.google.com\">www.google.com</a>")}

sashton avatar Jan 03 '16 02:01 sashton

On investigation, it looks like my suspicion is confirmed: https://github.com/JonyEpsilon/gorilla-repl/blob/develop/resources/gorilla-repl-client/js/renderer.js#L20

The event listener there is returning false. Maybe a solution would be to return false if alt is pressed, but true if otherwise, to allow normal href behavior to occur.

As a workaround, I added an ugly javascript onclick handler to get the navigation to happen:

#gorilla_repl.html.HtmlView{:content ("<a href=\"http://www.google.com\" onclick=\"window.open('http://www.google.com');\">google</a>")}

sashton avatar Jan 04 '16 01:01 sashton

This was done to stop the case where you click on a link and then lose your unsaved work in Gorilla, which is very annoying!

Having a modifier that allows you to follow the link (a bit like in MS Word) is a nice idea.

JonyEpsilon avatar Feb 24 '16 17:02 JonyEpsilon

Keeping unsaved work is definitely a good idea. In my snippet above I solved that by opening the link in a new browser window.

sashton avatar Feb 24 '16 18:02 sashton