Is it a bad idea to use window.open and try to communicate between windows?
I'm working on a web page that will have a google-reader type scrolling list of content, and I'd like to open that content when it's clicked on in a new window. The problem is that I'd really like to be able to update the scrolling list from one of the newly opened windows.
For example; I'm looking at a list of products for sale on my web page, and a user clicks one of the products,开发者_JS百科 opening a new page displaying details of the product they clicked on. The new page also includes links to various assortments of products (lets say teacups) - when the user clicks on 'show me some teacups', I'd like the original list of products to be redirected to the page showing all the teacups and focus to be transferred to this window (leaving the product-specific page open in another window/tab)
Is this a horrible idea? Will I have problems with popup blockers or security policies in newer browsers? Is this generally considered a bad design pattern?
Thanks for any input.
Popups are a delicate matter these days because of popup blockers. If at all possible, using inline dialog boxes like JQuery dialog is preferable - they all reside within one page, though, of course. But they're resizable, can be made modal and much more.
Other than that, as long as all your windows come from the same domain, I don't see any problems with cross-window communication, as long as you have only one parent that opens all the windows and that can serve as a broker in intra-window communication (the popup windows know only window.opener
).
OK, so to answer my own question (I need to stop asking questions before I really dig for answers), this is a very bad idea indeed - I knew it felt wrong. The basic problem is that it breaks the back button, which could potentially be remedied with some JS goodness, but it's still a bad idea from an accessibility standpoint. My guess is that the reason Google Reader does this by default is that it's explicitly an interface for viewing other pages, so the user shouldn't be surprised to find that the links open in new windows.
Some reading on the topic for anyone interested:
Top 10 Web Design Mistakes of 1999
W3C Mailing list discussion of a.target deprecation
精彩评论