Two Laptop Bag*
The moose likes HTML, CSS and JavaScript and the fly likes how to load HTML in DIV Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "how to load HTML in DIV" Watch "how to load HTML in DIV" New topic
Author

how to load HTML in DIV

accnit Jai
Ranch Hand

Joined: Feb 15, 2011
Posts: 33
I have one JSP page with two DIVs , one DIV to display the content and other to work as menu. In content DIV, I want to load the external HTML page. and I need to call some Java script function of content HTML (loaded in content DIV) to perform some function. When i am using :
document.getElementById("content").innerHTML =xmlhttp.responseText

innerHTML does not return the HTML page.

Can someone please let me know how I can load external HTML in my content DIV and also i can access their Java script function.

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

An HTML Page? As in, complete with the <html> tag and everything? If so, then you cannot. It is not valid to include an <html> element anywhere inside the DOM.

If you meant an HTML fragment, that's different.

Which do you mean?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
accnit Jai
Ranch Hand

Joined: Feb 15, 2011
Posts: 33
DIV content will have the linked to Javascript , CSS files and images.. no HTML tag.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

The just an HTML fragment, not a "page" (for that, you'd have to use an iframe).

So now you need to explain how you are "loading" the fragment and what you mean by "innerHTML does not return the HTML page".

And, this doesn't seem like a JSP problem at all, so I've moved this to the HTML forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to load HTML in DIV
 
Similar Threads
innerHTML and script in AJAX
DIV containing a script
IE doesn't seem to reflect updated document object
How to refresh DIV
Javascript issue when loading the JSP page content via an AJAX call