user1784971
user1784971

Reputation: 201

How to display a javascript result in HTML after the function is finished

I have this iframe on my website that can test your internet speed.

It has a callback function after the test is finished. This function can show various object properties. It now looks like this:

    <script type="text/javascript">
         function nPerfTestCompletedObj(object) {
              document.write(object.id);
     }
    </script>

Problem is that this way it shows the object id on a new blank page.

Anybody can help me out how to show the result below the iframe after the function is finished?

Upvotes: 0

Views: 181

Answers (1)

Manik Malhotra
Manik Malhotra

Reputation: 632

you need to create an empty p tag with an id like results. And show the object id on the results div.

Please use the below code

<p id="results"></p>

and then update your function like this:

<script type="text/javascript">
    function nPerfTestCompletedObj(object) {
        document.getElementById('results').innerHTML = object.id;
     }
</script>

You can create more p tags or div to show more properties.

Upvotes: 1

Related Questions