码迷,mamicode.com
首页 > Web开发 > 详细

js模拟form打开新窗口

时间:2018-10-13 12:50:28      阅读:242      评论:0      收藏:0      [点我收藏+]

标签:tar   create   targe   UNC   value   put   _for   col   openurl   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function openUrl(iid) {
            var temp_form = document.getElementById("item_form");
            if (temp_form == null) {
                temp_form = document.createElement("form");
                temp_form.action = "/xxx.aspx";
                temp_form.target = "_blank";
                temp_form.method = "get";
                temp_form.setAttribute("id", "item_form");

                var temp_input = document.createElement("input");
                temp_input.setAttribute("type", "hidden");
                temp_input.setAttribute("id", "item_id");
                temp_input.name = "id";
                temp_input.value = iid;
                temp_form.appendChild(temp_input);
                document.body.appendChild(temp_form);
            } else {
                document.getElementById("item_id").value = iid;
            }
            temp_form.submit();
        } 
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="javascript:openUrl(1)">a1</a>
    <br />
    <a href="javascript:openUrl(2)">a2</a>
    <br />
    <a href="javascript:openUrl(3)">a3</a>
    </div>
    </form>
</body>
</html>

 

js模拟form打开新窗口

标签:tar   create   targe   UNC   value   put   _for   col   openurl   

原文地址:https://www.cnblogs.com/webapi/p/9782337.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!