Asked  7 Months ago    Answers:  5   Viewed   39 times

I want home.html to load in <div id="content">.

<div id="topBar"> <a href ="#" onclick="load_home()"> HOME </a> </div>
<div id ="content"> </div>
<script>
      function load_home(){
            document.getElementById("content").innerHTML='<object type="type/html" data="home.html" ></object>';
  }
</script>

This works fine when I use Firefox. When I use Google Chrome, it asks for plug-in. How do I get it working in Google Chrome?

 Answers

88

I finally found the answer to my problem. The solution is

function load_home() {
     document.getElementById("content").innerHTML='<object type="text/html" data="home.html" ></object>';
}
Tuesday, June 1, 2021
 
LoicTheAztec
answered 7 Months ago
88

It seems that the onloadeddata property does not work for some reason. But attaching an event handler through addEventListener (or via jQuery) works: http://jsfiddle.net/3vxCu/4/

bgSound = new Audio();
bgSound.src = "http://www.ehsankia.com/hawkthorne/audio/level.ogg";
bgSound.preload = "auto";
// Standard browsers (not IE before version 9):
// bgSound.addEventListener("loadeddata", testFunction, false);

// jQuery:
$(bgSound).on("loadeddata", testFunction);

function testFunction () {
    alert("Data loaded");
}
Friday, July 30, 2021
 
RahulG
answered 4 Months ago
55

you can achieve vertical aligning with display:table-cell:

#section1 {
    height: 90%; 
    text-align:center; 
    display:table;
    width:100%;
}

#section1 h1 {display:table-cell; vertical-align:middle}

Example

Update - CSS3

For an alternate way to vertical align, you can use the following css 3 which should be supported in all the latest browsers:

#section1 {
    height: 90%; 
    width:100%;
    display:flex;
    align-items: center;
    justify-content: center;
}

Updated fiddle

Sunday, August 8, 2021
 
hnkk
answered 4 Months ago
42

The problem seems to be related to the browser hardware acceleration. Everything works fine as soon as I turn it off.

Hardware acceleration browser setting

However, I don't know if it's possible for my web page to disable hardware acceleration.

Sunday, August 15, 2021
 
Valdas
answered 4 Months ago
23

Try jquery..

function changeContent() {
    $('#content').load('Login.jsp');
}
Tuesday, November 9, 2021
 
elias
answered 3 Weeks ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share