I am making an HTML5/JavaScript Win 8 app and trying to add an AD on my HTML page from a js file. I am using the following code:
adDiv= document.createElement('div');
adDiv.setAttribute("id",
"myAd2");
adDiv.setAttribute("data-win-control",
"MicrosoftNSJS.Advertising.AdControl");
adDiv.setAttribute("data-win-options",
"{applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab', adUnitId: '10043105'}");
adDiv.setAttribute("style",
"width: 150px; height: 120px; border:solid 2px #000");
document.getElementById("xyz").appendChild(adDiv);
where div id="xyz" exists.
Yet, the AD div appears to be blank. Its just the black border that is visible.
The AD looks and works fine when directly placed in the HTML file:
<div id="myAd" style="width: 250px; height: 250px; z-index: 1" data-win-control="MicrosoftNSJS.Advertising.AdControl" data-win-options="{applicationId: 'd25517cb-12d4-4699-8bdc-52040c712cab', adUnitId: '10043105'}"> </div>
Can't ADs be added from a js file? This seems weird.