首页 > 其他 > 详细

关于popup

时间:2017-10-23 22:36:21      阅读:258      评论:0      收藏:0      [点我收藏+]
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,width: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>
 

关于popup

原文:http://www.cnblogs.com/jec1999/p/7719561.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!