使用 window.opener 在window.open打開的子頁面操作父頁面元素

最近需求越來越奇怪了  要在window.open()打開的頁面  點擊保存按鈕的時候 操作回顯父頁面的 百分比

查來查去  用window.opener方法解決  用到的方法主要有以下幾種

 

//相當於$("#..").html("...")
window.opener.document.getElementById(id).innerHTML = html 
//此爲操作父頁面中的函數window.opener.function
window.opener.initEcharts(res.object,data);
//爲父頁面設置元素 相當於$("#..").attr("url",newUrl)
window.opener.document.getElementById(id).setAttribute("url",newUrl);
//獲取父頁面的元素 相當於$("#..").attr("url")
window.opener.document.getElementById(id).getAttribute("url");
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章