Jump to content

How to launch an external script in PW to be embedded in the page

Recommended Posts

I was given this script to be embedded in the body of a page in order to automatically launch and render the destination link when the page is opened. 

<a href="https://www.iubenda.com/privacy-policy/*****" class="iubenda-white no-brand iubenda-embed" title="Privacy Policy ">Privacy Policy</a>
<script type="text/javascript">(function (w,d) {var loader = function () {var s = d.createElement("script"),
        tag = d.getElementsByTagName("script")[0]; s.src="https://cdn.iubenda.com/iubenda.js"; 
        tag.parentNode.insertBefore(s,tag);}; if(w.addEventListener) {w.addEventListener("load", loader, false);}
        else if(w.attachEvent){w.attachEvent("onload", loader);} else{w.onload = loader;}})(window, document);

How do I include it in PW? I tried using the CKEditor but it just outputs the script without launching it. If I include it in my template in PHP, it renders as a button that once clicked opens a new tab outside of my website instead of having the script being embedded inside my page. Do you have any suggestion about how to make this work?

Share this post

Link to post
Share on other sites

I believe that it's precisely what this script is supposed to do: embedding a button.


The standard (and our simplest) integration method consists of including the iubenda button or the link in the pages of your site, typically in the footer. This will open the privacy policy in a modal window (lightbox) when the link is clicked.


It seems like overkill to me: it's a just a link after all. I usually just convert it to a plain link, no script required:

<a href="https://www.iubenda.com/privacy-policy/xxxxx/legal">Politique de confidentialité</a>


Share this post

Link to post
Share on other sites

The script above is supposed to open the privacy in a modal. That's really the only added benefit I see here.

Share this post

Link to post
Share on other sites

Thanks for your feedback @jacmaes, I understand your point. Looking at your link though, one of the possibilities to include Iubenda is 'Direct text embedding' which renders the Iubenda page as embedded in your own page layout. Upon further searches, I realised that the only thing that was amiss from the script I was given is the class 'iub-body-embed' which launches the script automatically when opening the page (instead of rendering a button that opens a modal as you correctly pointed out). 

In order to be able to launch the script through PW, I had to install the module 'Inputfield ACE Extended' which allows to 'write' Javascript directly into the page. 

It might be a bit of a overkill, yet I think it looks easier to read when it's embedded in a page of its own, inside the website layout.  

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...