Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 
Story on base tag.
base tag story search bar.
Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format


Tips on managing links.
Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

JavaScript Tip:
Give Orphan Pages A Home

by Larisa Thomason,
Senior Web Analyst,
NetMechanic, Inc.

  
April 2002
Vol. 5, No. 7
 • Promotion Tip
 • Usability Tip
 • JavaScript Tip
  

Webmasters often use JavaScript to keep their pages out of other sites' frames. But the owners of framed sites have a different problem: keeping their framed pages together. Use this simple JavaScript code to prevent visitors from opening pages outside the frameset.

Search Engines Create Orphans

How do visitors even find pages outside your frameset? The culprit is often the NOFRAMES tag. You should always include it to give search engine spiders and visitors with non-supporting browsers a map of your site. But there is a downside.

When spiders crawl through your internal pages, they index each individual page and display them as standalone (or orphan) pages in search results. Think about most framed sites you've seen. They display a navigation bar in a narrow frame on the page's left side and display the content in a larger frame on the right. The navigation frame usually stays constant and visitors use it to view different pages in the content frame.

So when the content pages are displayed outside the frameset, visitors don't see the navigation system. Even internal site links on your content pages may not work because they're designed to load into a frameset. Visitors probably won't realize that the page should be in a frame and just assume that your site is full of broken links.

Send the Page Back To The Frame

In a previous frames article, we showed you how to redirect visitors to your site's home page when they try to load an orphaned page. That solution keeps the navigation structure intact, but may confuse visitors who think they're clicking on an article, but get your home page instead.

Now we're giving you a better solution, courtesy of Ted Ulle, moderator at Webmaster World discussion forums.

This script first checks to see if your content page is trying to display outside its frameset. If so, it redirects your visitor to a framed page and loads the orphan into an alternative frameset that you design. Visitors see the page they expect - in a format that allows them to navigate easily to other pages within the site.

As an added benefit, this is a framed page that visitors can bookmark! Most framed sites aren't bookmark friendly because the site URL stays the same no matter what page you're viewing in the content section. You also lose the benefits of word-of-mouth advertising (or is it word-of-email?) that comes when a visitor wants to share your site with a friend. This script makes both bookmarking and email sharing possible - but only if the visitors enter your site through an orphaned page instead of your home page.

Insert this code into the HEAD section of each page that should always display inside a frameset:

Then, create a new page and name it master.html. Leave the BODY section empty and place this code inside the HEAD section:

Note that this script creates a frameset that allots 20% of the frame size to the left frame and 80% to the right frame. You can adjust these as needed to accommodate your site.

Debugging And Maintenance

Even simple JavaScript code can cause debugging headaches. If your script doesn't seem to work properly, check these things first:

  • Spelling errors. Carefully check to see that the file names are spelled exactly the same. If you call the master frameset "master.html" in the JavaScript, but name it "Master.html", you'll get an error. Name your files and variables anything you want (other than reserved words), but you have to be consistent.

  • File paths. Check your file paths carefully when you test the pages offline. Netscape browsers are notoriously picky about paths. Then check them again - and edit if necessary - when you upload the pages to a live server.

  • Avoid line breaks. Don't insert line breaks in the document.write statement or JavaScript will assume that you have incorrectly terminated the statement.

Our Top 5 JavaScript mistakes article from December 2001 covers these and other common JavaScript coding errors in more detail.

Maintenance also becomes an issue if you're adding the same JavaScript code to multiple pages. Each time you restructure your site or rename affected pages, you have to update the code on every possible orphan page. Avoid this maintenance nightmare by using an external JavaScript file. It streamlines site maintenance and reduces the size of your HEAD section.

JavaScript coding errors will break these pages, but HTML coding errors can break pages or cause them to display inconsistently across browsers. Use NetMechanic's HTML Toolbox to find and fix HTML coding errors that can cause browser incompatibility problems.

NetMechanic's HTML Toolbox and Browser Photo tools will help you correct Web site problems and ensure that your orphan pages look great in their new home.



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2010,
Keynote NetMechanic
All rights reserved.