Javascript如何使用方法访问不同的html页面数据?

Javascript如何使用方法访问不同的html页面数据?,javascript,jquery,html,Javascript,Jquery,Html,我有两个HTML页面,showNutrition.HTML和showFounds.HTML。在showNutrition.html上,我有一个按钮,我想按下该按钮,在showFounds.html上的表格中添加一行用户输入的名称。我不确定如何编写javascript函数来访问showFinds.html。这是我目前掌握的代码 showNutrition.html按钮: `<a class="topcoat-button center full" onclick="saveMeals()"&

我有两个HTML页面,showNutrition.HTML和showFounds.HTML。在showNutrition.html上,我有一个按钮,我想按下该按钮,在showFounds.html上的表格中添加一行用户输入的名称。我不确定如何编写javascript函数来访问showFinds.html。这是我目前掌握的代码

showNutrition.html按钮:

`<a class="topcoat-button center full" onclick="saveMeals()">Save Meal As Favorite</a>`

如果ShowFines位于iframe中,则可以使用

document.getElementById('showMeals').contentWindow.document.getElementById('mealTable');
其中“showFines”是加载的iframe showFines.html的id属性

<iframe src='showmeals.html' id='showMeals'></iframe> 

某些浏览器可能使用contentDocument而不是contentWindow。参考资料在这里

JSFiddle将不胜感激。@NatZimmermann这个问题很难用小提琴重现。听起来他好像在使用框架或多个窗口。@acbabis啊,是的,我没有正确阅读问题。我找到了一个jquerys$.get方法的示例,但我不确定如何在更改不同页面上的数据时使用它。也许我更适合将收藏夹表与showNutrition放在同一页面上,但是“我的视图收藏夹”按钮是否可以打开和关闭表格?这样,添加到表中是很容易的。
document.getElementById('showMeals').contentWindow.document.getElementById('mealTable');
<iframe src='showmeals.html' id='showMeals'></iframe>