views:

35

answers:

1
<head>
<script language="javascript" type="text/javascript">

function openMe()
{
    var win = window.open("about:blank");
    var str="";
    for(var a in win){
        str+=a+"<br/>";
    }
    document.getElementById("data").innerHTML = str;
    win.document.write("Karandeep Singh");
}
</script>
</head>

<body>
    <div>
        <input type="button" value="OK" onclick="openMe()"/>
    </div>
    <div id="data">
    </div>

The above code is open a document and write on it. but it is not working in safari.

+1  A: 

you need proper html...

do it like this,

demo

function openMe()
{
    var win = window.open();
    var str="";
    for(var a in win){
        str+=a+"<br/>";
    }
    document.getElementById("data").innerHTML = str;
var windowHTML =
         "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'&gt;\n" +
         "<html>\n" +
         "<head></head>\n" +
         "<body>Hello World</body>\n" +
         "</html>";
      win.document.write(windowHTML);
      win.document.close();
}​
Reigel
Thanks.............
Karandeep Singh
just don't forget to accept... as I see in your acceptance rate is low...
Reigel