Design Usability
  Home arrow Design Usability arrow Page 2 - Building Friendly Pop-up Windows
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DESIGN USABILITY

Building Friendly Pop-up Windows
By: Alejandro Gervasio
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 28
    2005-02-02

    Table of Contents:
  • Building Friendly Pop-up Windows
  • Addressing the problems with pop-up windows
  • The JavaScript function
  • Adding style to pop-up close links

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Building Friendly Pop-up Windows - Addressing the problems with pop-up windows


    (Page 2 of 4 )

    When we’re working with browsers where scripting is disabled, the pop-up does nothing. It’s just that simple. Using standard <a href> expressions would help to solve this issue. The following code:

    <a href="#" onclick="window.open('file.htm');">Click here</a>

    is and old and inefficient way of opening pop-ups. We have to make sure not to intersperse inline JavaScript event handlers with HTML. They’re part of JavaScript, and should be coded within it. Even so, in order to make the link work, if scripting is disabled, we simply use:

    <a href="file.htm" onclick="window.open('file.htm');return false;">Click here</a>

    This way, if scripting is disabled, the standard link still works. The return false statement effectively cancels out the default action of the href section, so it won’t open the pop-up and the normal HTML windows at the same time. It will open one or the other. What’s more, if we want the window to open on top of the current window, just adding a target attribute will do the trick -- like so:

    <a href="file.htm" onclick="window.open('file.htm');return false;" target="_blank">Click here</a>

    The problem is now solved. But there are still some issues that need to be tackled. Let’s assume we’re using tools like Dreamweaver to keep links properly maintained. If we return to the code:

    <a href="file.htm" onclick="window.open('file.htm');return false;" target="_blank">Click here</a>

    The link above would be nicely maintained, at least for the "href" part. But the "onclick" section would probably be ignored. Again, the code might be changed to:

    <a href="file.htm" onclick="window.open('this.href');return false;" target="_blank">Click here</a>

    Now there is only one link to maintain, and the "this.href" expression would work for the "window.open" method. That’s pretty good! What about pop-up killers? As with the issue of JavaScript being disabled, by merely providing a standard "href" section, the link will still work.

    In order to solve accessibility problems, the most common approach is to inform the user that the link will open in a new window, include instructions as part of the link itself, and add notes in a title attribute or using proprietary icons to indicate that the link will open a pop-up window.

    Seemingly, we’ve found a decent solution to the common pitfalls with pop-ups. In fact, we’re still a ways from that. We’re working with ugly and confusing inline JavaScript handlers. It’s highly recommended, for good coding habits and easy of maintenance, to completely separate JavaScript from the HTML markup, as we’d normally do with server-side scripting languages. So our previous code:

    <a href="file.htm" onclick="window.open('this.href');return false;" target="_blank">Click here</a>

    is still not good enough, since the JavaScript code is embedded into the link. It would be fairly good to write a JavaScript function that will take care of solving most of the issues previously described, but keep our HTML entirely unharmed. Sound interesting? Let’s get our hands dirty and get ready for coding!

    More Design Usability Articles
    More By Alejandro Gervasio


       ·  The article deals with building pop-up windows. As mentioned on it, it'd be...
       · window.open('this.href') will try to find a file called this.href, the quotes are a...
       ·  Hello, You're right, quotes are my mistake. Should be read (this.href)...
       · On page 3 of the article there is something wrong with the content.Firefox...
       · Hello Mario,There are two additional semicolons in the JavaScript...
       · Hello,The whole function should work fine:<pre><html> </html>...
       · This function should work:<pre>createPopUp=function(){ ...
       · I found your article from Google and think it is very very useful to create friendly...
       · Thank you for the comments on this tutorial. Of course, I'm glad to know that it's...
       · I am now in the process of using your friendly pop ups, but being a bit of a...
       · Hello Brian,Thank you for commenting on my article. In response to your...
       · Firstly let me thank you... in spades.Sadly it did not work in that I got a...
       · Hi again Brian,Thanks you for your comments. I'm sorry my solution didn't work...
     

    DESIGN USABILITY ARTICLES

    - Create Great JavaScript and CSS Menus Simply
    - Design Principles that Shape a Web Site
    - Creating Aqua Style Images
    - Easy as A,B,C – dynamic A to Z indexes
    - EasyChart: a Usability Teaching Tool to Demo...
    - Building Friendly Pop-up Windows
    - Back to School: Design Usability
    - Using HTML_QuickForm To Manage Web Forms, Pa...
    - Using HTML_QuickForm To Manage Web Forms, Pa...
    - More Website Knick Knack
    - Browsers as Test Platforms
    - Website Knick Knack
    - Dynamic Page Elements-Cloak and Dagger Web D...
    - Accessibility and Dreamweaver MX 2004







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway