|
Using iframes - instead of windows created via window.open - to show external content from a foreign domain has two big advantages: (i) iframes can be more easily customized than new windows created via window.open and (ii) popup blockers won't stop external content shown in an iframe from appearing. The advantage given in (ii) is real when a new window is not explicitly requested by the person using the browser i.e. when the window's appearance is attached to such events as onload and onunload. But the advantage is only appearant when the window's appearance is attached to an onclick event on a link (and other events that can be taken to mean that a person has explicitly requested a new window). When the browser sees that a new window is actually requested, it won't allow popup blockers to do their job. So preferring an iframe to window.open() is not always obvious. And there's a specific case in which iframes should not be used. If the page contained in it has links leading to other pages, each click on a link adds an entry to the browser's history. This may lead to a situation where the number of entries in the history surpasses the one corresponding to the number of visited 'main pages'. When this happens, the browser's back button may not function correctly anymore, because browsers don't distinguish between history entries recorded in the main page(s) and entries recorded in an iframe. From this it follows that we should use the window.open method rather than an iframe if the external page has hrefs on it. In modern browsers, window.open opens a new tab by default, instead of opening an 'old fashioned' new window. But there may be cases in which we don't want a new tab. We would prefer the old fashioned new window when we want to explicitly show that an external page must be seen as an essential part of the existing 'main page'. This very page contains a script ensuring that an external page opens in a new window (not in an iframe or a new tab) when the visitor clicks on a link. Features:
The HTML, just an example: <a href="javascript: void(0)" onclick="pop_it_up('http://www.google.com',70, 80)">Google</a> In this example, the Google page opens in a (centered) new window that takes up 70% of the screen's width and 80% of the screen's height. DEMO: The links on this page. Notes:
Arie Molendijk http://www.mesdomaines.nu/music |