Python 从django中的iFrame读取元素
我使用以下代码访问IFrame中的复选框元素。由于复选框的状态,我希望收到一条消息,但它总是响应:“复选框未选中”。我如何解决该问题Python 从django中的iFrame读取元素,python,django,iframe,django-templates,Python,Django,Iframe,Django Templates,我使用以下代码访问IFrame中的复选框元素。由于复选框的状态,我希望收到一条消息,但它总是响应:“复选框未选中”。我如何解决该问题 def main_page(): if request.method == 'GET': return render_to_response('main.html') elif request.method == 'POST': if request.POST.get('checkbox1', False):
def main_page():
if request.method == 'GET':
return render_to_response('main.html')
elif request.method == 'POST':
if request.POST.get('checkbox1', False):
return HttpResponse("The check-box is checked.")
else:
return HttpResponse("The check-box is not checked.")
def iFrame():
if request.method == 'GET':
return render_to_response('MyIFrame.html')
elif request.method == 'POST':
return
其中,这是main.html的模板:
<form>
<iframe src="MyIFrame.html"></iframe>
<input name="button" type="submit" id="button" value="ok">
</form>
这是MyIFrame.html的模板:
<input type="checkbox" name="checkbox1" id="checkbox1">
您为什么要这样做?iframe不是同一文档的一部分,表单数据将不包括来自iframe的任何输入。为什么不使用普通模板继承呢?iframe
是一个完整的单独文档,它不是父页面中表单的一部分。我知道iFrame独立于父页面,但是有没有办法从父页面访问其元素?