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
Release: 2024-11-16 11:46:03
Original
1023 people have browsed it

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>';
}
Copy after login

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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template