zoukankan      html  css  js  c++  java
  • 关于popup

    p1.html:点击添加按钮,开启窗口,打开p2.html,填写数据后返回p3.html,p3.html将数据回传到p1.html,且关闭自己
     
    p1.html:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
     
    <select name="" id="s1">
        <option value="">北京</option>
        <option value="">天津</option>
    </select>
    <button onclick="add()">添加</button>
     
    <script>
        function add() {
            window.open('/p2/',"dsdsd","status=1,height:500,600,toolbar=0,resizeable=0")
        }
     
        function xxxxxxxx(name) {
            var option = document.createElement("option")
            option.innerHTML=name
            option.setAttribute("selected",true)
            document.getElementById("s1").appendChild(option)
        }
    </script>
    </body>
    </html>
     
     
    def p2(request):
        if request.method=='GET':
            return render(request,"p2.html")
        elif request.method=='POST':
            obj = models.UserGroup.objects.create(title=request.POST.get("city"))
            return render(request,"p3.html",{"obj":obj})
     
    urlpatterns = [
     
        url(r'^nb/', v1.site.urls),
        url(r'^p1/', p1),
        url(r'^p2/', p2),
     
    ]
     
     
    p2.html:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <form method="post">
        {% csrf_token %}
        <input name="city" type="text">
        <input type="submit" value="提交">
    </form>
     
    </body>
    </html>
     
    p3.html:
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>正在返回</title>
    </head>
    <body>
    <script>
        (function () {
            var name = "{{ obj.title }}";
            window.opener.xxxxxxxx(name);
            window.close()
        })()
    </script>
    </body>
    </html>
     
  • 相关阅读:
    java_监控工具jvisualvm
    bzoj3667: Rabin-Miller算法
    bzoj3677: [Apio2014]连珠线
    4070: [Apio2015]雅加达的摩天楼
    4069: [Apio2015]巴厘岛的雕塑
    4071: [Apio2015]巴邻旁之桥
    bzoj2653: middle
    1500: [NOI2005]维修数列
    bzoj4262: Sum
    bzoj4540: [Hnoi2016]序列
  • 原文地址:https://www.cnblogs.com/jec1999/p/7719561.html
Copyright © 2011-2022 走看看