I need to dinamically add some simple maps in a page. When I try this static code it works
<iframe src="http://maps.google.it/?ie=UTF8&ll=45.442726,12.3925788&t=w&z=12&output=embed&iwloc=near"></iframe>
But if I try to add that iframe dinamically with this code
var HTMLiframe = document.createElement("iframe");
var code = "src=https://maps.google.it/?ie=UTF8";
code += "&ll=" + itemMap.latitude + "," + itemMap.longitude + "&t=w";
code += "&z" + itemMap.zoom;
code += "&output=embed&iwloc=near";
HTMLiframe.setAttribute("src", code);
HTMLelemFather.appendChild(HTMLiframe);
UPDATED:
An error message is logged: Refused to display document because display forbidden by X-Frame-Options
How can I solve?
You are doing this:
Change it to:
this part assigns it to the src attribute of the iframe element: