Search code examples
javascriptroundcube

Insert script at login page - Roundcube


I'm trying to insert that Mcafee Security etiquette into my web page. Mcafee gave me the following code:

<script type="text/javascript" src="https://cdn.ywxi.net/js/1.js" async> </script>

However, it does not appear on my page when I add it.

I'm adding in the <head> tag. The page to which I am inserting is in the following location:

/home/apache2/old/newmail/skins/george

Login.html


Solution

  • You need to make sure the website you are trying to insert it on is registered and currently being used. The script looks at the location.host, here would be stackoverflow.combefore sending the code to display the actual element. Note the line with setting the src attribute.

    try{
        var v=document.createElement("script");
        v.setAttribute("type","text/javascript");
        v.setAttribute("src","//cdn.ywxi.net/js/host-loader.js?h="+location.host);
        document.getElementsByTagName("head")[0].appendChild(v)
    }catch(e){};
    

    You can test this by going to the website cdn.ywxi.net/js/host-loader.js?h=<YOUR HOST HERE> and confirm there is JavaScript sent back.