开发者

How to set parent window values to child window?

开发者 https://www.devze.com 2023-03-18 19:36 出处:网络
How to set parent window values to child window? In parent window i have few textboxes. When i enter some values and click on button i need to get those values in child window. I am using HTML and ja

How to set parent window values to child window?

In parent window i have few textboxes. When i enter some values and click on button i need to get those values in child window. I am using HTML and javascript. I need this in javascript or jquer开发者_开发知识库y. Please help me. Thanks in advance.


In your parent window, you should have a function:

//parent window
function getParentValue(){
  return $("#textbox").val();
}

You can call this function in your child window:

//child window

var parentValue = window.opener.getParentValue();
alert(parentValue);

This works because functions are public by default (not like vars)

Hope this helps. Cheers

0

精彩评论

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