Home >Web Front-end >JS Tutorial >Why does my JavaScript code fail to load an HTML page into a div in Chrome?

Why does my JavaScript code fail to load an HTML page into a div in Chrome?

Susan Sarandon
Susan SarandonOriginal
2024-11-16 11:46:031037browse

Why does my JavaScript code fail to load an HTML page into a div in Chrome?

Loading an HTML Page in a div Using JavaScript

Problem:

Inserting an HTML page into a div element using the innerHTML property fails in Google Chrome due to a prompt for a plug-in.

Solution:

The correct type attribute value for the object element is "text/html," not "type/html."

Code Snippet:

function load_home() {
  document.getElementById("content").innerHTML='<object type="text/html" data="home.html" ></object>';
}

The above is the detailed content of Why does my JavaScript code fail to load an HTML page into a div in Chrome?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn