我有一个类似下面的html代码。
index.html
<html>
<head>
<script>
user_data = {
name: 'xyz',
age: 123
}
</script>
</head>
<body>
.... some code ---
<iframe src="test.html"></iframe>
</body>
</html>
test.html
<html>
<head>
<script>
$(document).ready(function(){
var userName = user_data.name;
});
</head>
<body>
<!--- some other code -->
</body>
</html>
基本上,我正在尝试从test.html(iframe文件)访问index.html中的user_data对象。
[有人可以帮助我在iframe中获得价值。