Forum Moderators: open

Message Too Old, No Replies

Showing/Hiding block based upon the filename

         

ktigre

9:35 pm on Jul 27, 2004 (gmt 0)



I have a program that generates a HTML page. the only thing I can modify is the header and footer of the page. I've tweaked things so that I have descriptions for what it generates in a cell to the right of the generated stuff. However the header is used on a large number of pages, so I need to show certain blocks of HTML code depending on what the filename is. if this was ASP I'd have no problem, but because the page is just HTML I am stuck with javascript unless someone else knows another way to do it.

IE.
the pages might be called printers.html and servers.html The header file is the same for both, but depending on which page loads the header I need it to show a particular set of tables on the page.

If anyone can help, it would be greatly appreciated.

Rambo Tribble

3:52 am on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not sure what the nature of the block you wish to hide or show is, but if you gave it an id value you could either manipulate its display value or its visibility value, something like:

if(document.URL=="http://document_URL_1" ¦¦ "http://document_URL_2" ¦¦ ~etc.)document.getElementById("target_ID").display="none";
else document.getElementById("target_ID").display="block";

Rambo Tribble

3:34 pm on Jul 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A further note: You would need to wait until the document had finished loading to run the script (to make sure the element was available), so you would want to call it with the onload event.