"Insert into post" – Inserting form data from a pop-up window into the main window
I have a button labeled "Upload image", when you click the button it opens a pop-up window with a small image uploader in there. When you upload an image, I want it to say "Insert into post开发者_Python百科" in the pop-up window and when you click that it then inserts the filename of the image into the post.
I've already got a way to get the filename, all I need to know is how to SEND the data from the pop-up box form and put it into the main window.
Any ideas?
Thank you in advance
You can use the opener property of the pop-up window to find an hidden input in the main window:
window.opener.document.getElementById('id_of_hidden').value = 'something';
When you open a pop-up window, the
window.opener
property will point to the parent window. You will be able to proceed from there.
MDC documentation on window.opener
window.opener.document.data = data_from_popup;
精彩评论