Title: Pop up content editor blocking me from adding Javascript?
Last modified: April 21, 2020

---

# Pop up content editor blocking me from adding Javascript?

 *  Resolved [samsun34567](https://wordpress.org/support/users/samsun34567/)
 * (@samsun34567)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/pop-up-content-editor-blocking-me-from-adding-javascript/)
 * Hi,
 * I’m building a pop up which includes an onclick event.
 * [Add to favorites](https://wordpress.org/support/topic/pop-up-content-editor-blocking-me-from-adding-javascript/void(0)?output_format=md)
 * -> Like this.
 * .
 * Is this disabled due to some security concerns? I’m pretty it’s plugin specific
   since on simple posts it works.
 * Thank you.

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

 *  [Predrag – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support1/)
 * (@wpmudev-support1)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/pop-up-content-editor-blocking-me-from-adding-javascript/#post-12713028)
 * Hi [@samsun34567](https://wordpress.org/support/users/samsun34567/),
 * Could you provide me with some more information about how the setup actually 
   looks?
 * If I understand this correctly, you are adding the code inside the popup content
   by using Text editor, is that right?
 * Could you share the exact code that you’re using so we could check it out further
   on our end?
    Please make sure to use CODE tag to wrap the code or share a link
   to GitHub/PasteBin so that the formatting doesn’t get affected.
 * Cheers,
    Predrag
 *  Thread Starter [samsun34567](https://wordpress.org/support/users/samsun34567/)
 * (@samsun34567)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/pop-up-content-editor-blocking-me-from-adding-javascript/#post-12717461)
 * Hi Predrag,
 * Thanks for getting back to me.
 * So we set up a function for users to add our page to their bookmark with a click
   on the button using Javascript. This is what the script looks like:
 *     ```
       function rudr_favorite(a) {
       	pageTitle=document.title;
       	pageURL=document.location;
       	try {
       		// Internet Explorer solution
       		eval("window.external.AddFa-vorite(pageURL, pageTitle)".replace(/-/g,''));
       	}
       	catch (e) {
       		try {
       			// Mozilla Firefox solution
       			window.sidebar.addPanel(pageTitle, pageURL, "");
       		}
       		catch (e) {
       			// Opera solution
       			if (typeof(opera)=="object") {
       				a.rel="sidebar";
       				a.title=pageTitle;
       				a.url=pageURL;
       				return true;
       			} else {
       				// The rest browsers (i.e Chrome, Safari)
       				alert('Press ' + (navigator.userAgent.toLowerCase().indexOf('mac') != -1 ? 'Cmd' : 'Ctrl') + '+D to bookmark this page.');
       			}
       		}
       	}
       	return false;
       }
       ```
   
 * And the button:
    `<a href="javascript:void(0)" onClick="return rudr_favorite(
   this);">Add to favorites</a>`
 * This works well on regular pages. However if I add the button html to the pop-
   up, it will only go to a 404 page with an URL of {pageurl}/void(0). And if I 
   go back to check on the pop-up editor, the html will be stripped away of the 
   Javascript component, leaving only
 * `<a>Add to favorites</a>`
    -  This reply was modified 6 years, 1 month ago by [samsun34567](https://wordpress.org/support/users/samsun34567/).
 *  Plugin Support [Dimitris – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support6/)
 * (@wpmudev-support6)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/pop-up-content-editor-blocking-me-from-adding-javascript/#post-12733496)
 * Hello there [@samsun34567](https://wordpress.org/support/users/samsun34567/)
 * I was able to replicate the stripping of the hyperlink attributes in Main Content
   using the Text editor.
    I’ve created a task for our developers about it, if there’s
   any development on this we’ll keep you posted here. 🙂
 * Thank you,
    Dimitris

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

The topic ‘Pop up content editor blocking me from adding Javascript?’ is closed 
to new replies.

 * ![](https://ps.w.org/wordpress-popup/assets/icon-256x256.gif?rev=3446944)
 * [Hustle - Email Marketing, Lead Generation, Optins, Popups](https://wordpress.org/plugins/wordpress-popup/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-popup/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-popup/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-popup/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-popup/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-popup/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Dimitris – WPMU DEV Support](https://wordpress.org/support/users/wpmudev-support6/)
 * Last activity: [6 years, 1 month ago](https://wordpress.org/support/topic/pop-up-content-editor-blocking-me-from-adding-javascript/#post-12733496)
 * Status: resolved