...

View Full Version : [ASK]Overlay?? Is that possible?



alvin_bilian
01-06-2007, 03:09 PM
Is that possible if we wanna 'destroy' all the current page html content, and then replace it with the new one using javascript?
Please tell me folks?!:thumbsup:

david_kw
01-06-2007, 11:17 PM
I think it kind of depends what you mean by "all". All visible info on the page? All info even non-visible? You can try something like this to see what might answer your question.

<button onclick="document.write('hi');">Hi</button>

david_kw

Kor
01-07-2007, 07:21 AM
I guess you must detail your aim. You may do that using javascript, but why to do to that when you may simply load another page...?

alvin_bilian
01-08-2007, 10:28 PM
I mean the visible one to be replaced..
Yeah, that example you given is working like an overlay.
But what about the full HTML page to be replaced??:confused:
I'm looking for these anywhere, but not find it out...

david_kw
01-08-2007, 10:43 PM
I'm sure I drive Kor crazy with my non-DOM answers but how about this!



<button onclick="document.getElementsByTagName('body')[0].innerHTML='<div>Click <a href=\'http://www.google.com\'>here</a> to go to Google.</div>';">Make new page</button>



I have to admit I still don't understand what you are trying to achieve.

david_kw

alvin_bilian
01-10-2007, 02:13 PM
okay thanks its working, but only replaced the body tag..
what about all inside the HTML tag to be replaced?
Can this be done?

david_kw
01-10-2007, 03:47 PM
Ok I'm done guessing. First I showed one way to overwrite the whole thing and you said you only wanted the visible stuff replaced. Then I showed a way to replace the body and you want to replace more. I'd need solid information on what you do and don't want changed to try and help more.

david_kw

alvin_bilian
01-11-2007, 08:28 AM
Okay, sorry for the less info i've given...
The detail is:
I want to replace all the tag inside the HTML tag..
including head and body tag...

So that's it..
I wanted to make a site that when some1 click the link the page are all updated with the new one..

david_kw
01-11-2007, 04:07 PM
Well I don't have any idea how to set everything between the <html> tags. From my limited tests the

document.getElementsByTagName('html')[o].innerHTML =

assignment didn't work.

But it seemed to work to overwrite the whole page using document.write() as shown in this test.



<html>
<head>
<title>Old Page</title>
<script type="text/javascript">
var htmlHead =
"<title>New Page</title><script>function set(){document.getElementById('adiv').innerHTML='adiv';}<\/script>";
var htmlBody =
"<div>Click <a href='http://www.google.com'>here</a> to go to Google.</div><button onclick='set();'>Test DOM</button><div id='adiv' />";
var htmlPage =
"<html><head>" + htmlHead + "</head><body>" + htmlBody + "</body></html>";
</script>
</head>
<body>
<button onclick="document.write(htmlPage); document.close();">Replace with document.write</button>
</body>
</html>


Of course, I have no idea what the ramifications are across browsers or anything else. But it was interesting that it did seem to parse it in to the DOM (as shown by the button).

david_kw



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum