Find and Replace in HTML Tags

The HTML Tags tab in the Find and Replace dialog is the perfect tool for complex searches inside HTML code. The HTML Tags tab should not be confused with the same functionality provided by HTML Rules. HTML Rules allow you to precisely control which HTML tags are returned in a Find or Replace operation and can be used in conjunction with settings on the HTML Tags tab. The HTML Tags tab allows you to specify how HTML tags are modified during a Find and Replace operation.

Suppose you have created a Web site that serves as an HTML reference. You have set most of your hyperlinks with a target of _self, but you haven't set these by setting a base target. Instead, you have set the target on each individual hyperlink. After the site is complete, you decide that you would like to replace the target of these hyperlinks to _blank so that they will open in a new window.

Because this is a site about HTML, you have several occurrences of target=_self in tutorials throughout the site that is actual text in the site and not HTML code. You don't want these to be replaced. You only want to replace the text if it is actually part of the HTML code itself. This is a common scenario, and in past versions of FrontPage, this type of complex replacement would have been impossible. However, now it is not only possible, but quite easy to do.

Open the Find and Replace dialog by selecting Edit, Replace and click the HTML Tags tab. Because you want to find only those incidents of your text that are inside of the <a> tag, select a from the Find Tag dropdown box. In the Replace Action dropdown, select Set Attribute Value. In the Attribute dropdown, select target, and in the To attribute dropdown, select _blank (see Figure 5.7).

Figure 5.7. Complex replace functions are made easy with the HTML Tags feature.

graphics/05fig07.jpg

If you run the replace as it's currently configured, it will set the target attribute on every hyperlink to _blank. Because you only want to change those tags with a current target attribute of _self, you will need to configure an HTML Rule to control the Replace operation.

Click the HTML Rules button. You'll see that HTML Rules currently has one rule labeled Find tag: <a>. Click the New rule entry and select With Attribute in the New Rule dropdown. In the [any attribute] dropdown, select target and in the [any value] dropdown, select _self (see Figure 5.8).

Figure 5.8. HTML Rules allow you to carefully control what text is found and replaced.

graphics/05fig08.jpg

Your Find and Replace dialog should now indicate that an HTML Rule is in place by displaying With attribute: target = _self. You now have a query defined that will search for all <a> tags with a target attribute equal to _self. When it finds them, it will change the target attribute to _blank.



Special Edition Using Microsoft Office FrontPage 2003
Special Edition Using Microsoft Office FrontPage 2003
ISBN: 0789729547
EAN: 2147483647
Year: 2003
Pages: 443

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net