最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Pass a value from Parent to Child (Open) window - Stack Overflow

programmeradmin1浏览0评论

How to pass value from parent to child window field. I use window.open("www.google");

after popwindow is opened i need to pass/set search value typed in parent window to child window(www.google)

How to pass value from parent to child window field. I use window.open("www.google.");

after popwindow is opened i need to pass/set search value typed in parent window to child window(www.google.)

Share Improve this question asked Apr 20, 2010 at 19:47 minilminil 7,15516 gold badges51 silver badges57 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2

Set a reference using the window.open() method:

var childWin = window.open("www.google." <etc.>);

Then treat childWin as a whole other window. For example,

childWin.document.getElementById('searchField')

will give you a reference to an element with ID of "searchField". Etc. Rinse and repeat.

If you want to open a page or window with sending data POST or GET method you can use a code like this:

$.ajax({
    type: "get",  // or post method, your choice
    url: yourFileForInclude.php, // any url in same origin
    data: data,  // data if you need send some data to page
    success: function(msg){
                console.log(msg); // for checking
                window.open('about:blank').document.body.innerHTML = msg;  // you can change  about:blank  to an url.
               }
}); 
发布评论

评论列表(0)

  1. 暂无评论