本文介绍了IFrame和父窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

iframe可以在父页面上安装cookie或会话吗?如何在不使用Ajax的情况下在iframe中获取iframe的值?我试图将id值从iframe传递到父页面,然后提交它。

Can an iframe install a cookie or session on the parent page? How do i get value in an iframe to the parent page without using Ajax? I am trying to pass an Id value from the iframe to the parent page and then submit it.

推荐答案

在iframe中,您可以使用 parent.document 。如果你的父窗口中有一个输入字段并想在不使用AJAX的情况下在其上设置一个值,你应该只需使用JavaScript就可以执行以下操作:

From within your iframe, you can reference the parent document using parent.document. If you had an input field in your parent window and wanted to set a value on it without using AJAX, you should simply be able to do the following using JavaScript:

parent.document.getElementById('myInputId').value = 'some value';
parent.document.getElementById('yourFormId').submit();

您也可以在父页面中调用函数:

You can call functions in your parent page as well:

parent.someFunction();

我不确定从子框架操纵父级的cookie,但是你的帖子看起来您需要做的就是存储并提交一个值。只用PHP就无法做到这一点。

I'm not sure about manipulating a parent's cookie(s) from a child frame, but your post it seems like all you need to do is store and submit a value. You won't be able to do it with just PHP.

这篇关于IFrame和父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-07 03:03