Web App on iPhone - problem that links open in new Safari window

I have a web app that I’m writing for the iPhone which searches a DVD database and displays results. Each result has a link to the movie’s IMDb (Internet Movie Database) page. The web app is designed to be added to -and launched from- the iPhone’s Home Screen which means the Safari back and forward buttons are not displayed. This has resulted in an unforeseen problem - if the user activates the IMDb link they will go the the IMDb page but then there is no way to go back to the web app’s results page they just left.

My solution is to use a ‘top bar’ which has 2 links on it which invoke the javascript history.back() and history.forward(), and also a home link which goes straight back the the results page. To implement this my HTML body has just 2 things, the top bar code and object/embed code which displays the IMDb page. See this example code:

<body>

<div id="topbar">
  <div id="backlink"><a href="javascript:history.back()"><img src="Icons/arrow_left.png"/></a></div>
  <div id="homelink"><a href="res.php"><img src="Icons/arrow_home.png"/></a></div>
  <div id="forwardlink"><a href="javascript:history.forward()"><img src="Icons/arrow_right.png"/></a></div>
</div>

<object data="http://m.imdb.com/title/tt1375666/" width=100% height=100000>
<embed src="http://m.imdb.com/title/tt1375666/" width=100% height=100000></embed></object>

</body>

I have a problem though - after an IMDb page has loaded, when some links are pressed instead of opening in the web app, Safari starts automatically and the link loads in that, this is really annoying because now the user can not return to the results page, the web app is closed and when finished with the IMDb page(s) the user has to start the web app again and re-enter the search details. The back and forward links in my top bar work fine but the ‘home link’ (which just loads my results php page) always opens in a new Safari window [Note. my top bar’s home link does not use TARGET=“_blank”, I tried using TARGET = “_self” but the home link still opened in a new Safari window.]

Strangely this only happens with some links on IMDb and not all (these are just normal page links not video trailer ones). Also if I open the web app’s URL in Safari, do a search, and activate an IMDb link, there is no problem with links opening in a new window/tab, that does not happen ever.

Is there any way to stop the links opening Safari?

Thanks.