Recoding iWeb Sites Part 2: Manipulating Code for iWeb-Created Page Elements
As discussed in the first article of this two-part series on recoding iWeb sites, iWeb does not allow you to directly edit HTML code in the Web pages you create by using it. As a workaround, you can open the files using an alternate Web design application such as Dreamweaver, or you can use a text editor to add code or to modify pages. Part one of this series focused on locating the files that iWeb creates and showed you how to add very small pieces of code to them, such as the many free Web services—like blogrolls—require. This article goes looks more deeply at the actual HTML code that iWeb creates on individual pages.
Before getting into discussion about code, however, let’s talk about the reasons you might want to modify the code of an iWeb site. Sometimes you might be required to add a bit of code to a page for a specific service. You might also want to remove or modify items that iWeb automatically creates, most notably the navigation bar that it puts at the top of each page.
Beyond that, you may want to add Flash animation or Java applets, image maps, or forms to page. These types of elements are fairly common and basic enough that most people can place them on a page. There are tons of ready-made applets and scripts out there to add custom features to a Website without requiring you to know much about how the code actually works, but they are a little bit more involved than simply placing a single line of code into a page. Even if you are a proficient Web designer, you might choose to use iWeb because it is a quick and easy method for creating basic personal pages. Plus you still have the option to add more complex custom elements if you want.
iWeb’s user-friendly interface makes it an attractive tool for developing concept sites for clients or projects. If you’re a professional or semiprofessional designer, you might be called on to develop a handful of ideas to pitch for a new site or a redesign of a site in a short amount of time. iWeb can be a simple way to create those concept pieces for a design meeting. However, after a design is selected, you face the prospect of actually building a site with more functionality and cleaner code than iWeb allows. Similarly, you might initially create a site in iWeb and then determine that you need to use a broader set of tools for what you want to accomplish with that site.
Removing or Revising the Navigation Bar
Let’s start with the most obvious element that you might want to change in an iWeb site: the navigation bar. iWeb automatically creates this bar regardless of which template you use and it does so without any real consistency from one template theme to another. Also, unlike some of iWeb’s required text boxes, you cannot alter the navigation bar (although you can specify whether each page is displayed in it). Although the navigation bar is a nice feature, it is also one of the things that marks a site as obviously having been created using iWeb, and the variation between themes prevents you from having a consistent look at the top of each page throughout your site (unless you choose a single theme).
Experienced Web designers can probably identify the code that creates the navigation bar pretty easily. For the less-experienced, however, all the style elements on an iWeb page can seem hard to separate. Typically, the navigation bar begins with the third <div> tag on the page (the first and second identify the dimensions of the page and the style of the background). This tag always includes id="nav_layer". The code for the navigation bar then continues with more style information, images for each page listed in the navigation bar, and several blocks of code that create the links and make the calls to the page’s JavaScript file to create the mouseover effects.
Each graphic and link/mouseover effect section is contained within its own <div> tags. The link and mouseover sections can be identified because they begin with an anchor (<a>) tag and contain items such as onmouseout="NBmouseout(’11’) and onmouseover="NBmouseover(’11’). After the last of these sections, there’s a single </div> tag and then the content of the rest of the page.
To completely remove the navigation bar from a page, delete all these sections of code. Once the code is removed, you can add a navigation menu of your own. If you have the skill and experience, you can also modify the images and/or script elements of the navigation bar on your own. If you have a large number of pages, you’ll need to remove the relevant code from each one. Also, because iWeb generates a separate folder containing the images, JavaScript, and stylesheet for each page, you cannot use a global search-and-replace feature (which most Web design applications and text editors offer) to remove the navigation bar from all pages of a site at once.