lundi 24 février 2020

Triggering a link via a checkbox in only HTML and Javascript

Is there a way of launching a link from clicking/tapping on a checkbox with only HTML and CSS (no JavaScript)?

I'm scripting something for personal use and looking for a way to launch a URL scheme by checking a checkbox.

It is trivial to write a checkbox that "has" a link:

<a href="kmtrigger://macro=some%20macro"><input type="checkbox" name="checkbox" id="done" value="value"></a> Test

Hovering over the checkbox reveals the link (as shown in this CodePen sample of the above code). Still, I cannot get the link to launch. It seems like the checkbox action "absorbs" clicks.

I have tried giving the link a higher z-index, but it had no effect.

(There are other ways of achieving this that I will probably pursue, but this is the simplest if it is possible!)




Aucun commentaire:

Enregistrer un commentaire