Changing Tag Attribute Values
You’d think that with so many
HTML tag attributes reflected as scriptable properties, it would be
simple enough to modify the look of many elements by adjusting their
properties after the document has loaded. Unfortunately for
compatibility, of the currently released scriptable browsers, only
Internet Explorer 4 lets you adjust highly visible attributes on the
fly. This is because the rendering engine in the browser does a nice
job of reflowing a page’s content in response to a change of
any property. Therefore, you can increase the size of an
IMG element by altering the
height and width properties of
the object, and the content around and below the image is shifted to
make room for the bigger picture. If you try to do this with
Navigator 4, however, a script error message reminds you that these
properties are read-only in that browser.
In fact, if you are aiming for cross-platform compatibility in
altering the physical appearance of a currently loaded document, your
possibilities are very limited. Outside of form element values (e.g.,
the contents of a text box, selected items in a checkbox, the state
of a radio button, and selected list options), about the only tag
attributes you can alter from a script in Navigator are the
image object’s src
attribute (as described in the previous section) and the
document’s bgColor property. Even the
document.bgColor property has some caveats when the page is being run in Navigator 2 or 3 on an operating system ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access