Skip to content
Advertisement

Third party survey onto popup div

I am trying to load a third party survey onto a popup and it’s not working. Where am I making a mistake?

This should happen on a click a button or href. So I am creating a iframe dynamically.

$('<iframe id="myFrame" name="myFrame" width="400" height="400">').appendTo('body');

then loading the data to it..

var myIframe = document.getElementById("myFrame");
var script = myIframe.contentWindow.document.createElement("script");
script.type = "text/javascript";
script.src = "https://www.surveygizmo.com/s3/2296429/Advertisement-Feedback?_output=embedjs"
myIframe.contentWindow.document.body.appendChild(script);

I am interested in any other ideas to achieve this; I cannot make a ajax call as it is going to complain about the cross domain thing.

Advertisement

Answer

Check your console for error messages, you will see:

Uncaught SyntaxError: Unexpected token <

Which means that you have a “<” somewhere in your javascript where it should not be.

Now, navigate to https://www.surveygizmo.com/s3/2296429/Advertisement-Feedback?_output=embedjs

Note that the is an html file which you are trying to load into a script tag.

Change your code to this:

$('<iframe id="myFrame" name="myFrame" width="400" height="400">').appendTo('body');

var myIframe = document.getElementById("myFrame");
myIframe.src = "https://www.surveygizmo.com/s3/2296429/Advertisement-Feedback?_output=embedjs"
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement