Technote 10006: Using clean to change all links to a specific window
A link also stores a reference to the window the link will display in.
If you want to change all links in a project currently pointing to one window
to to point to another window, you can use the clean system to do this.
In this example we will replace all links to the window called second
with a link to the window called third.
Note: This technote assumes that you have already
read Technote 10005: Introduction to cleaning HTML code.
Overview of how windows are stored
In HTML, all links store the window or frame to display the link in on the
target attribute of the a tag. In the HyperText Studio you can specify
both a window AND a frame to display a link in, so Olson Software have added
two new attributes that are used on the <a> tag in the HyperText Studio:
||The frame to display the link in.
||The window to display the link in
In addition, the target attribute is used to hold the frame or window to display
the link in. These are the rules used to decide what to place in the target
- If a frame is specified, but no window, target is the frame and olsframe
and olswindow are not used.
- If a frame and window are specified, target is the frame and olsframe is
the frame, and olswindow is the window.
- If a window is specified, but no frame, target is the window and olswindow
is the window.
This information is important in designing a clean to change window names.
When you want to change the window a link points to you have to change not just
the target attribute (only if it points to that window), but the olswindow attribute.
Setting up a clean
With the information we have just learnt, we can create a new clean that will
find any link tags that have an target attribute with the text second.
We will then change the attribute value to be third.
We will then do the same with the olswindow attribute.
- Create a new clean set and name it linkclean.
- Add a new match.
- Fill out the boxes as displayed below:
- Now we want to create an action that will change the target attribute's
value from second to third. To do this, we add a new action of type
Add Attribute (which, if the attribute exists, simply replaces the attribute's
existing value). At this point you could equally use the Remove Attribute
action if you wanted to completely remove references to a given window.
Add a new action and fill it out as displayed below:
- Repeat steps 3 and 4 with olswindow
as the attribute name (rather than target).
- Your window should now look like this:
- Click OK.
- Select the linkclean clean
and click OK.