I have been tasked to add a script file to a page when you click a button. Thought this would be easy. The script displays a popup a user can fill in a form.
I have my button click working and it adds the script file to the page and calls the script file I want calling.
function loadPopUp() {
var script = document.createElement('script');
script.src = "/js/patpopup.js";
var body = document.getElementsByTagName("body")[0];
body.appendChild(script);
console.log("clicked");
return false;
}
In the script I was given it is just a url //r1.dotmailer-surveys.com/scripts/popover/111111?a=uc
that was wrapped in script tags.
I can't get the popup to open it only takes me to the page where all the script is.
If I wrap it in script tags and place it in the page it opens ok.
What should I put in the patpopup.js
file that the script url
is in, I have tried using window.location
and various other methods to try and get the page to open in the page and produce the popup but always opens the script instead of running it.
At the minute I only have the url //r1.dotmailer-surveys.com/scripts/popover/111111?a=uc
in my patpopup.js file