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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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();
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.