• Resolved samsun34567

    (@samsun34567)


    Hi,

    I’m building a pop up which includes an onclick event.

    Add to favorites

    -> Like this.

    However every time I press save, the editor strips away the javascript part and only leaves Add to favorites.

    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)
  • Hi @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

    (@samsun34567)

    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.
    Plugin Support Dimitris – WPMU DEV Support

    (@wpmudev-support6)

    Hello there @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.