iPhone Safari Web App opens links in new window

Pavel Linkesch picture Pavel Linkesch · May 24, 2010 · Viewed 127.4k times · Source

I have problem with web after adding icon to Home Screen. If the web is launched from Home Screen, all links will open in new window in Safari (and lose full screen functionality). How can I prevent it? I couldn't find any help, only the same unanswered question.

Answer

Pavel Linkesch picture Pavel Linkesch · May 24, 2010

I found JavaScript solution in iWebKit framework:

var a=document.getElementsByTagName("a");
for(var i=0;i<a.length;i++)
{
    a[i].onclick=function()
    {
        window.location=this.getAttribute("href");
        return false
    }
}