开发者

Pass a value from Parent to Child (Open) window

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

after popwindow is opened i need to pass/set search value typed in parent开发者_StackOverflow社区 window to child window(www.google.com)


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

var childWin = window.open("www.google.com" <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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜