WordPress.org

Ready to get started?Download WordPress

Forums

WP Code Highlight
window.onload conflicts with other plugins (1 post)

  1. the_champ
    Member
    Posted 1 month ago #

    Hi there,

    You have used following code in "wp-code-highlight.php" file

    window.onload = function(){prettyPrint();};

    which does not let run the window.onload function defined in other plugins/themes activated at websites. This, in turn, breaks the functionality of the website which uses your plugin.
    So, you must change that code to following:

    function boliqOnLoad(func){
    			var boliqOldOnLoad = window.onload;
    			if (typeof window.onload != 'function') {
    				window.onload = func
    			} else {
    				window.onload = function () {
    					boliqOldOnLoad();
    					func()
    				}
    			}
    		}
    		boliqOnLoad(function(){
    			window.onload = function(){prettyPrint();};
    		});

    Above will not cause conflict with window.onload function of any other plugin/theme.

    https://wordpress.org/plugins/wp-code-highlight/

Reply

You must log in to post.

About this Plugin

About this Topic