开发者

window.open in javascript?

开发者 https://www.devze.com 2023-01-06 14:29 出处:网络
<head> <script language=\"javascript\" type=\"text/javascript\"> function openMe() { var win = window.open(\"about开发者_开发知识库:blank\");
<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.


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'>\n" +
         "<html>\n" +
         "<head></head>\n" +
         "<body>Hello World</body>\n" +
         "</html>";
      win.document.write(windowHTML);
      win.document.close();
}​
0

精彩评论

暂无评论...
验证码 换一张
取 消