user3416803
user3416803

Reputation: 379

Click on iframe using javascript

I have an iframe advertisment on my site, and i want when I click it to automatically opens in another tab. But I don't really know how to do it. I am trying with that way but it isnt working:

document.getElementById("ad_frame").contentWindow.document.body.click()

Upvotes: 0

Views: 79

Answers (1)

Eda190
Eda190

Reputation: 679

You can simply do it by window.open() function. Like that:

 <script language="javascript">
 window.open("http://www.ad-site.com");
 </script>

If this doesn't answer the question, please specify the question better.

Upvotes: 1

Related Questions