Friday, December 19, 2008

Writing text to an iframe in Javascript

A simple example - writing text to an iframe - note that if you don't close() the document each time then firefox shows you it's still downloading the outer page content - on vista you'll see the circle of download.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="" >


    <title>Untitled Page</title>




<script type="text/javascript">

    var i = 0;

    function doThing() {


        var a = document.getElementById("stepsAchieved");

        a.contentWindow.document.write("Here again " + i + "<br/>");




<input type="button" value="hello" onclick="doThing();return false;" id="fred"/>

<hr />

        <iframe src="" id="stepsAchieved" name="garminStepsAchieved" frameborder="1" height="200px" width="340px" scrolling="auto">




No comments:

Post a Comment