I would like to enable javascript to be added inside CKEditor. The editor filters all my javascript and I would like to make a transtision from an image to a youtube iframe, here is the code that I am using:

<div id=“hideThisVideo” style=“display:none;”><iframe frameborder=“0” height=“360px” src=“//www.youtube.com/embed/W10F0ezCTIQ?autoplay=1” width=“640”></iframe></div><img style=“width:640px;height390px;cursor:pointer;”src=“/sites/all/themes/gloriajesus/video.png” onclick=“this.style.display=‘none’;document.getElementById(‘hideThisVideo’).style.display=‘block’;”/>

But when I click nothing happens, it filters the "onclick" event and adds a paragraph tag:

<div id=“hideThisVideo” style=“display:none;”><iframe frameborder=“0” height=“360px” src=“//www.youtube.com/embed/W10F0ezCTIQ?autoplay=1” width=“640”></iframe></div> <p><img src=“/sites/all/themes/gloriajesus video.png” style=“cursor:pointer; height:390px; width:640px”></p>

I am using CKEditor with the module Wysiwyg.

Thanks in advance.

  • 1
    Could you please paste code as code, not as images? It would be easier to read, and it would make your question easier to find using search engines. They can't read from images that well.
    – Mołot
    Mar 21, 2014 at 16:30
  • I did it but the editor did erase my code, that`s why I had to it making screenshots of what I was writing. Mar 22, 2014 at 16:00
  • You didn't mark code as code. There is a button for that on the toolbar when you edit.
    – Mołot
    Mar 24, 2014 at 8:58
  • 1
    Thank you, I just did change it, I did not see that in the editor. Mar 25, 2014 at 11:28

2 Answers 2


Hope this will help you, For achieving your goal you need to create a plugin of ckeditor, First of all read more about ckeditor plugin, and create a view to get all the video with the display in a page, you can use the views page url for the ckeditor plugin to insert the media on ckeditor, a good tutorial is here.Click Here

this is one of the module which will help you click here & click here

  • Thank you! These plugins are very interesting but I have almost all done with Quicktabs and views, what I just wanted to do is to insert the "onclick" event in the field that CKEditor gives me, actually I was reading that I can do it disabling this: docs.ckeditor.com/#!/guide/… But I do not find where is the file to disable. Mar 21, 2014 at 9:53
  • Yes exactly, even you can perform on ok() of the plugin.js, you can reconstruct your java script.
    – madhurjya
    Mar 21, 2014 at 9:58
  • Thank you again, it worked but only for the first time, it is weird, only in Full HTML, not filtered, and when I enter again to my content to edit it, the onclick event disappears. Now it is working for example: gloriajesus.com Mar 21, 2014 at 10:13
  • Check may be somewhere your jquery library conflicts:)
    – madhurjya
    Mar 21, 2014 at 10:18
  • Anyway it is working with little glitches but working, thanks for all! Mar 21, 2014 at 12:05

A partial fix it can be done editing the plugins.js file that is inside /sites/all/libraries/ckeditor that was created when we added CKEeditor with Wysiwyg. Then adding inside the {} of the script that we see there:

config.allowedContent = true;

With this we allow all type of content and we desactivate the Advanced Content Filter (ACF) of CKEditor, but besides that we must use the Full HTML of Drupal, not the filtered.

Adding the code to the CKEditor field we can not edit it again without losing all the javascript loaded in the first time that we saved the content, we will lose it, but we can add it again.

Thats all, thanks to madhurjya for helping!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.