Last active
January 2, 2016 14:44
-
-
Save watershed/4a2c49e4b68caa508542 to your computer and use it in GitHub Desktop.
CraftCMS: force links in field instructions to open in a new window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Craft permits Markdown in its field instructions but doesn't permit raw HTML. | |
That's a pain when you want your field instructions to have links to documentation | |
elsewhere, because one would want such links to open in a new window. | |
So, with Lindsey DiLoreto's 'Control Panel JS' plugin (https://github.com/lindseydiloreto/craft-cpjs) installed, | |
just use it to add… | |
*/ | |
var links = document.querySelectorAll(".instructions a"), i; | |
for (i = 0; i < links.length; i++) { | |
var link = links[i]; | |
link.target = '_blank'; | |
link.title = 'Opens in a new window'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment