Improving the Pop-Up Pages
There are several ways in which a web application can figure out whether a page should be presented in a pop-up format or in a full-blown format with logo, navigation bars, sidebars, and footers (let’s call them non-content elements):
- On the server, you can check the referer HTTP header. If the referring page belongs to the same web, the page is presented in a pop-up format; otherwise it includes the non-content elements. This method isn’t completely reliable, however, as it depends on the browser’s proper handling of the referer header.
- You could also add a parameter to the query string when a page is launched in a pop-up window. The server-side application would then check this parameter and omit the non-content elements if the parameter is present. The query string can also be checked on the browser (with the location.search property), so this method also works for static pages.
The last method is the most robust; it’s the one we used in our solution. It requires only a single change in the convertPopupLinks function, adding the popup parameter to the pop-up window query string:
If your server-side application is well organized and has all the non-content elements grouped in an include file, the change in the pop-up pages is minimal; you just need to check for the presence of the popup parameter and execute the code in the included files if it’s present. The ASP version of the server-side code is shown in Listing 2.
Listing 2 Adding non-content elements to pop-up pages.
<% Dim isPopup isPopup = Request.QueryString("popup").count > 0 If Not isPopup Then %> <!-- #include file=commonHeaderElements.asp --> <% End If %> ... page content ... <% If Not isPopup Then %> <!-- #include file=commonHeaderElements.asp --> <% End If %>