Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Include another HTML file in a HTML file

Posted by: Alan7799 Dec 19 2022, 09:33 AM

Hi,

I am trying to include another HTML file in a HTML file using JavaScript.

I have tried many solutions given on the web and have not found one that works. I am a beginner with HTML and JavaScript, so I need all the details.

Thank for any help
Alan

Posted by: Christian J Dec 19 2022, 02:36 PM

This one should work: http://www.dynamicdrive.com/dynamicindex17/ajaxincludes.htm --at least if you test it from a web server. None of my newer browsers allow this script on HTML files that I open directly from my local file system. For security reasons, the included file must be hosted by the same domain as the page displaying it ("Same Origin Policy"), but browsers don't understand that the local file system is the same "domain" for both the parent page and the inclusion file. If you check the browser's javascript console there may be an error message about this.

Posted by: Alan7799 Dec 19 2022, 03:42 PM

Thank you for your replay.

I am trying to open the HTML file from my local file system.

Thank you for the explanation why that will not work.

Alan

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)