Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clearing the HTML page 2

Status
Not open for further replies.

bdavis96

Programmer
Feb 11, 2002
97
0
0
US
Is there HTML or JavaScript that I can use to clear a webpage so I can start fresh halfway through my code?

Example:

<Body>
<Table>
</Table>
<Table>
</Table>

Clear the page so those two tables go bye bye.

<Table>
</Table> This table should now be at top of page

</Body>

Any help would be much appreciated.



 
How do you mean? Like when a user clicks a button or automatically?

If its automatic, why not just delete the tables from your code in the first place?

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
Everything is in tables and the first two tables have things that I want loaded (text, pictures, etc) as the page is executing. Further down the code, I have a table loading that I want to show that the top of the screen and get rid of everything else that has previously loaded. Is there a way in the middle of my code to get rid of things previously loaded without loading a new page...I.E. clear page or clear inside tables or something to that nature.
 
Still not fully understanding your question. Do you want the page to automatically refresh to get rid of the two tables and display the third instead?

maybe this could be translated to your desires: thread215-751526

do a keyword search for "meta refresh"

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
You can place all elements to be deleted in a <div> tag. And when you want to delete it, just set its visibility style attrubute to hidden:

For IE:
Code:
divName.style.visibility = "hidden"
divName.style.visibility = "visible"
for other elements to fill in the gap:
Code:
divName.style.display = "none";
divName.style.display = "block";

For Netscape:
Code:
document.divName.visibility = "hide"
document.divName.visibility = "show"
I am not sure if the display attribute works in Netscape, but give it a try.
 
for: usefulness and multiplatform code

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
Is there a html (or Javascript) command like refresh or clear or something like that, that will clear the html page regardless of what was on it before and without going to a different page and it has to work in the <body> section.
 
did you not see my post about meta refresh?

you could write a javascript for <body onload="refresh"> but i dont see the point... why load a page only to instantly refresh it? thats a waste of bandwidth. what are you trying to achieve

~*Gwar3k1*~
&quot;To the pressure, everything's just like: an illusion. I'll be losing you before long...&quot;
 
I still stand by my last post as the best way to do this. In short, the answer to your question is no. The browser does not buffer the content, it just spits it out as it gets it. So, by placing the content you want to delete inside a div tag, you can do exactly what your are asking. And I checked, it does work in Netscape ( at least 6+). Check out this code, it should show exactly what you want to do. Just paste all this into a page and run it in a browser and see if this is what you want:

Code:
<html>
<head>
<script language="javascript">
function deleteBlock(){
  if (document.all) {
    document.all["deletedCode"].style.display = "none";
  } else if (document.getElementById) {
    document.getElementById("deletedCode").style.display = "none";
  }	
}
function showBlock(){
  if (document.all) {
    document.all["deletedCode"].style.display = "block";
  } else if (document.getElementById) {
    document.getElementById("deletedCode").style.display = "block";
  }	
}
</script>
</head>
<body>
Deleted code below:<br />
<div id="deletedCode">
Delete me
</div>
Deleted code above
<a href="#" onClick="deleteBlock()">Delete</a>
<a href="#" onClick="showBlock()">Show it</a>
</body>
</html>
 
Again, if you don't want the code below it to move up, then use the visibility attribute I stated above.
 
And of course if you really want to p**s people off by suddenly changing the page, you could use Flash.




Chris.

Indifference will be the downfall of mankind, but who cares?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top