vivek kumar choubey
vivek kumar choubey

Reputation: 55

Unable to load html file through javascript

list.html is not loading. Is this the correct way to load html file?

<div id="subscription"> </div>
<script>
    var i;
    for (i = 0; i < 5; i++) {
        document.getElementById("subscription").innerHTML = '<object type="text/html" data="list.html"></object>'
    }
</script>

Upvotes: 1

Views: 75

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167250

You cannot use:

<object type="text/html" data="list.html" ></object>

Best advice could be using <iframe>s:

<div id="subscription"> </div>
<script>
var i;
for (i = 0; i < 5; i++) {
  document.getElementById("subscription").innerHTML = '<iframe src="list.html"></iframe>';
}
</script>

But not sure why you need to loop it 5 times. You can just do:

<div id="subscription"> </div>
<script>
  document.getElementById("subscription").innerHTML = '<iframe src="list.html"></iframe>';
</script>

Upvotes: 1

Related Questions