create ad.html and put ur javascript code and add it under "files" in your construct 2 project. And "On Start of Layout" ==> HTML_iFrame.setURL("ad.html")
This should load the frame with your javascript.
You can also call refresh every 15 seconds to refresh ur ad.
System ==> Every 15 seconds ==> HTML_iFrame.refresh
Another note, run your project in a mobile device , because most advertisers don't show the ad if it's coming from a desktop browser.