devxlogo

Changing a Layer Through a Link

Changing a Layer Through a Link

Question:
Can I change the text of my layer through a link? I’ve heard it’s impossible and that I have to change the visibility of the layer and replace it with a new one. Is this true? I’m using Dreamweaver 2 on Windows 98.

Answer:
It’s perfectly possible to change the text of a layer through a link. The trick to it is to write to the element in question using:

document.layer[elementName].document.write(yourText) 

It’s an ugly notation, but it works for now. Then close just the element’s body. The following script, for example, will update a counter every time you click on the link:

	UntitledI have clicked on thislink 0      times.

If you want to add to the layer rather than overwrite it, simply omit the close() statement.

See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist