<script type="text/javascript">
    var n=1;
    function start() {
        timename=setInterval("set()",1000);
    }
    
    function set(){
        document.getElementsByTagName("p")[0].innerHTML =n++;
        if(n==11){
            clearInterval(timename);
        }
    }
</script>
</head>

<body onload=start()>
    
    <p></p>
</body>
public class XX {
    public static void main(String[] args) throws InterruptedException {
        for (int i = 1; i <= 10; i++) {
            System.out.println(i);
            Thread.sleep(1000);
        }
    }
}