Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

loading html page inside div

how can I load an html page inside a div. With the 'object' tag it's loading, but I think it's not a good approach. It is not an external file. Is dojo good for this?

like image 282
coder247 Avatar asked Aug 25 '10 09:08

coder247


People also ask

How do I load an HTML page into a div?

To load external HTML into a <div>, wrap your code inside the load() function. To load a page in div in jQuery, use the load() method.

How do I display one HTML page inside another?

The HTML <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document.

Can onload be used with a div?

The onload event can only be used on the document(body) itself, frames, images, and scripts. In other words, it can be attached to only body and/or each external resource. The div is not an external resource and it's loaded as part of the body, so the onload event doesn't apply there.


2 Answers

Use jquery

$("#mydiv").load("myexternalfile.html");
like image 133
Starx Avatar answered Oct 01 '22 11:10

Starx


I'm not completely sure what you're looking for, but if you're wishing to display an HTML document inside another HTML document then I think the only way to do this is to use an iframe. Check out this tutorial: http://www.designplace.org/tutorials.php?page=1&c_id=1

Perhaps you could load the HTML document and strip away the HEAD and wrapping BODY elements and then insert the code into the DIV element.

EDIT: Ah, no iframes you said. Well, then I propose the latter. ^^

like image 31
gablin Avatar answered Oct 01 '22 11:10

gablin