Home >Web Front-end >JS Tutorial >Why Does My JavaScript Code Load HTML in Firefox but Prompts for a Plugin in Chrome?
Loading an HTML Page into a Div Using JavaScript in Google Chrome
Question:
I'm attempting to load the "home.html" page into a div with the id "content" using JavaScript. The code works in Firefox, but it prompts for a plug-in in Google Chrome.
Code:
<script> function load_home() { document.getElementById("content").innerHTML = '<object type="type/html" data="home.html"></object>' } </script>
Solution:
To resolve the issue in Google Chrome, modify the "type" attribute within the "object" tag as follows:
function load_home() { document.getElementById("content").innerHTML = '<object type="text/html" data="home.html"></object>' }
By changing the "type" attribute to "text/html," the browser will now correctly load the HTML page into the specified div, eliminating the prompting for a plug-in.
The above is the detailed content of Why Does My JavaScript Code Load HTML in Firefox but Prompts for a Plugin in Chrome?. For more information, please follow other related articles on the PHP Chinese website!