overwrite existing html

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

overwrite existing html

Post by Illusionist »

I have a link to a pop-up, that is the same page but is going to load different information. Well, what i want is to clear the existing html on the pop aup and then do whatever with it. I've tried several different ways:

Code: Select all

<script>
document.innerhtml="";
</script>

Code: Select all

<script>
window.document.innerhtml="";
</script>

Code: Select all

<body onload="document.innerhtml=''">

Code: Select all

<body onload="window.document.innerhtml=''">
But none seem to work! Anyone have any suggestions??
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

hmm... But i just tried:

Code: Select all

<a href="javascript:document.innerhtml=''">here</a>
and loaded the page and clicked the link and it cleared it, but why wont it work if i do the same in the body onload ??
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

anyone? anything?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

what if:

Code: Select all

<html>
<head>
<script type='text/javascript'>
function cleardoc() &#123;
  document.innerHTML='';
&#125;
</script>
</head>
<body onload='window.setTimeout(cleardoc, 300); return true;' >
</body>
</html>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

Nope that doesn't work either. I'd tried that before, but it didn't work.... And it still doesn't
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

<head>
    <script type='text/javascript'>
    function clearBody() &#123;
        document.body.innerHTML = '';
    &#125;
    </script>
</head>
<body onload='clearBody();';>
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

That doesn't work either! What in the world is wrong with this?!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ever try:

Code: Select all

<body onload="document.write('')">
? IE6 SP2 won't let it write out, by default.. but everything else should..
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Illusionist wrote:That doesn't work either! What in the world is wrong with this?!
That does work in Opera 7.2x, Firefox 0.8 and ie6 sp1
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Wow, that's odd. It works fine for me in IE 6.

Code: Select all

<head>
    <script type='text/javascript'>
    function clearBody() &#123;
        document.body.innerHTML = '';
    &#125;
    </script>
</head>
<!--<body onload='clearBody();'>-->
ahahhaahahahahah
a
hah
ah
ah
a
ha
hah
ah
ah
a
h
<a href="#" onClick="clearBody();">clear!</a>
You can take the comment out of the body for it to clear on load.
Image Image
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

feyd wrote:ever try:

Code: Select all

<body onload="document.write('')">
? IE6 SP2 won't let it write out, by default.. but everything else should..
That does work, but then i can't output anything else... And all the other suggestions DO NOT work for my with what I'm doing in any of the browsers you said. What is happening is im loading the same page in a pop-up, but before i check the url and output what i need, i include the header and stuff. But what i'm trying to do is clear what the include included so i have a blank page to output what i need. And it would really suck to have to move the headers around and put them in like 20 different places, so If i can't get this to work, i may have to do that...
Post Reply