How to load an HTML page in Javascript

Solved
Perlogic -  
zellfurath Posted messages 248 Status Member -
Hello,

I have an HTML page built using two DIVs. The DIVs are placed one below the other.

For example:

<DIV id="f_1">
and
<DIV id="f_2">

On an ONCLICK action, I call a Javascript function that I created, this function should load an HTML page that is on my hard drive. But my problem is that I don't know how to load this page to display it in the DIV f_2.

Do you have any ideas on how to do that?

Thank you very much

Perlogic
Configuration: Windows XP Internet Explorer 7.0

11 answers

Perlogic
 
Yes, I found a trick.

 <html> <head> <script language="JavaScript" type="text/javascript"> function loadPage(url){ document.getElementById('if').contentWindow.document.location.href=url; } </script> </head> <body> <div id="f_1"> <button onclick="javascript:loadPage('http://www.google.be');">Click to load the div below</button> </div> <div id="clear" width="640" height="480"></div> <div id="f_2"> <iframe id="if" width="640" height="480"> </iframe> </div> </div> </div> </body> </html> 


Perlogic
15