montapro Posted May 4, 2017 Posted May 4, 2017 I want to allow JavaScript as a href attribute in CKEditor. In [myfield] > [Input] > [Custom Config Options] i'm added "linkJavaScriptLinksAllowed: true", but it doesn't work. Could someone help?
Robin S Posted May 4, 2017 Posted May 4, 2017 Hi @montapro, welcome to the PW forums. It's likely that HTML Purifier will strip javascript links regardless of the CKEditor config. So I think you'll have to set "Use HTML Purifier" to "No" in the field options if you want to insert links like that. JS links worked for me with HTML Purifier off. 1
montapro Posted May 4, 2017 Author Posted May 4, 2017 3 hours ago, Robin S said: Hi @montapro, welcome to the PW forums. It's likely that HTML Purifier will strip javascript links regardless of the CKEditor config. So I think you'll have to set "Use HTML Purifier" to "No" in the field options if you want to insert links like that. JS links worked for me with HTML Purifier off. Thank you @Robin S, is not the perfect solution, because pw shows me an error after save and edit the link in CKEditor. But at least it's saved and it is enough for my case.
Robin S Posted May 4, 2017 Posted May 4, 2017 9 hours ago, montapro said: is not the perfect solution, because pw shows me an error after save and edit the link in CKEditor. What is the error? Maybe there is a solution for this too.
montapro Posted May 5, 2017 Author Posted May 5, 2017 8 hours ago, Robin S said: What is the error? Maybe there is a solution for this too. It's saved and it works for me, but when i want to edit the link it promt an error and the "Link to URL" field is empty. Take a look at the screenshot.
Robin S Posted May 5, 2017 Posted May 5, 2017 1 hour ago, montapro said: It's saved and it works for me, but when i want to edit the link it promt an error and the "Link to URL" field is empty. Unfortunately there's no good solution to this that I can see while still using ProcessPageEditLink (i.e. the link modal window). That's because ProcessPageEditLink applies $sanitizer->url to existing link hrefs and the options for it are not configurable within the module. And even if the options were configurable it turns out that it's impossible for javascript links to pass this sanitizer because PHP's FILTER_VALIDATE_URL is always applied. The workings of ProcessPageEditLink seem a bit inconsistent to me so I have opened a GitHub issue. A workaround you could use is to create a Hanna code for inserting javascript links, with attributes for 'href' and 'text'. If you install Hanna Code Dialog you can get a dialog UI in CKEditor. 1
montapro Posted May 5, 2017 Author Posted May 5, 2017 Good idea. I will try it later. Thank you @Robin S
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now