IFrame and Parent window

2019-08-02 11:15发布

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.

标签: php iframe
1条回答
Viruses.
2楼-- · 2019-08-02 12:03

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.

查看更多
登录 后发表回答