我有两页父页和子页,我必须将所选值从子页添加到父页。下面是我的父页面代码。
function lookup(){
window.open('https://c.ap4.visual.force.com/apex/accountpopup','popuppage','width=400,toolbar=1,resizable=1,scrollbars=yes,height=400,top=100,left=100');
}
function updateValue(param)
{
document.getElementById("name").value = param;
}下面是我的孩子/弹出页面代码:
function callaccount(param){
var parent1=window.dialogAruments;
var v=param;
parent1.updateValue(param);
window.close();
}弹出窗口不会关闭并将值发送到父页。
发布于 2017-04-12 10:41:15
您可以使用window.opener。请注意,窗口中还有其他函数,如window.open、window.self、window.top和window.parent。但是在您的例子中,window.opener更相关,因为它引用了名为window.open(...)的窗口,所以您的函数应该是:
function callaccount(param){
var parent1=window.dialogAruments;
var v=param;
window.opener.updateValue(param);
window.close();
}谢谢!
发布于 2017-04-12 11:32:20
使用jQuery本地存储
您的代码应该类似于要传递值的page1:
if (typeof(Storage) !== "undefined") {
// Store
localStorage.setItem("variable", "value");
}
else {
console.log("Sorry, your browser does not support Web Storage...");
}您需要这些数据的page2:
if (typeof(Storage) !== "undefined") {
// Retrieve
console.log(localStorage.getItem("variable"));
}
else {
console.log("Sorry, your browser does not support Web Storage...");
}在console中查看输出,让我知道它是否对你有帮助!
发布于 2017-04-12 10:43:54
使用window.opener
您需要在您的子页面中使用window.opener,如下所示。
childWindow.opener.document.getElementById('<id from parent form>').value = '123';opener属性返回对创建窗口的窗口的引用。
当使用window.open()方法打开窗口时,可以使用子窗口中的此属性返回父窗口的详细信息。
https://stackoverflow.com/questions/43367029
复制相似问题