Title: Inline JavaScript being removed when switching views
Last modified: August 22, 2016

---

# Inline JavaScript being removed when switching views

 *  Resolved [darkhorse20](https://wordpress.org/support/users/darkhorse20/)
 * (@darkhorse20)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/inline-javascript-being-removed-when-switching-views/)
 * I don’t recall this happening before with this widget. Recently when I add inline
   JavaScript to a link like:
 * `<a href="#" onclick="doSomething(); return false;">Click Here</a>`
 * The inline Javascript is removed when switching to Visual view. After switching
   from Visual view back to Text view, the link now looks like:
 * `<a href="#">Click Here</a>`
 * Is this a bug or is the inline Javascript being removed on purpose?
 * [https://wordpress.org/plugins/black-studio-tinymce-widget/](https://wordpress.org/plugins/black-studio-tinymce-widget/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Marco Chiesi](https://wordpress.org/support/users/marcochiesi/)
 * (@marcochiesi)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/inline-javascript-being-removed-when-switching-views/#post-5472603)
 * This is not depending on our plugin, you may verify that the same thing happens
   when editing posts/pages. It depends on the TinyMCE configuration, which by default
   doesn’t consider valid the onclick attribute, so it strips it. It’s possible 
   that on previous versions of WordPress/TinyMCE the behavior was different.
    You
   may alter the default behavior using custom code with the [tiny_mce_before_init filter](http://codex.wordpress.org/Plugin_API/Filter_Reference/tiny_mce_before_init)
   or with a specific plugin like [Advanced TinyMCE Configuration](https://wordpress.org/plugins/advanced-tinymce-configuration/)(
   I did not test it). See also [TinyMCE documentation on valid_elements parameter](http://www.tinymce.com/wiki.php/Configuration:valid_elements)
   for details.
 *  Thread Starter [darkhorse20](https://wordpress.org/support/users/darkhorse20/)
 * (@darkhorse20)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/inline-javascript-being-removed-when-switching-views/#post-5472615)
 * I get it now. I was able to use the [Advanced TinyMCE Configuration](https://wordpress.org/plugins/advanced-tinymce-configuration/)
   plugin to add extended_valid_elements parameters and stop the “onclick” from 
   being stripped. Thanks for the help!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Inline JavaScript being removed when switching views’ is closed to new
replies.

 * ![](https://ps.w.org/black-studio-tinymce-widget/assets/icon.svg?rev=2627604)
 * [Black Studio TinyMCE Widget](https://wordpress.org/plugins/black-studio-tinymce-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/black-studio-tinymce-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/black-studio-tinymce-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/black-studio-tinymce-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/black-studio-tinymce-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/black-studio-tinymce-widget/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [darkhorse20](https://wordpress.org/support/users/darkhorse20/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/inline-javascript-being-removed-when-switching-views/#post-5472615)
 * Status: resolved