Forcing links to open in new browser window

Can someone share Javascript code to force links to open in a new browser window?

The link will be ad generated by Javascript code.

Here is a bit more detail about my situation. I am creating a web-based mobile app. In other words, the native app acts just like a set of frames that load web pages. One of the frames loads an ad. The ad is invoked via javascript provided by various mobile ad networks.

On the iPhone, we are noticing the ad loads within the ad frame inside the app, instead of spawning a new browser window. We would like to resolve this w/ javascript code that forces all links (specifically links generated via javascript) to open in a new browser window.

Thanks.

The only way to “force” it is to open it in the same window as an overlay in front of the existing page.

Your visitors have full control over what opens in a new window, what opens in a new tab and what overwrites the current page.

What I’m looking for is when the ad/link is clicked… it opens in a new window.

The click is happening from within the app, not a browser.

So you will need to hard code opening a new window into the non-browser app.

Right, my question is what that code would look like.

The ads are created via Javascript (e.g. like an AdSense ad). I feel like, w/ Javascript, I should be able to create some behavior tied to certain tags and/or actions that will make clicked links resolve in new windows.

Please let me know if my question is unclear and I can clarify. Thanks.

Here’s an example to explain my situation…

Let’s say this is the contents of my HTML file:

<script src="http://3rdpartysite.com/ad.js" type="text/javascript"></script>

Let’s say this is the contents of the 3rd-party ad Javascript file:

document.write("<a href=http://advertiser.com><img src=http://3rdpartysite.com/ad.gif border=0></a>");

Is there Javascript that I can add into my HTML file to add the new window behavior (e.g. target=“_blank”) to the link being generated by the 3rd-party Javascript file?