【发布时间】:2021-10-05 03:02:36
【问题描述】:
我有一个应用程序,我正在使用 iframe 插入另一个应用程序,如下所示
父应用
<HTML>
....
<body>
<iframe firstname="Trump" src="https://on.co/onboarding/" height="600" allowfullscreen="" >
</iframe>
</body>
</html>
儿童应用
<HTML>
....
<body>
<h1> Covid is deadly if you doubt ask the indians </h1>
<script>
const urlParams = new URLSearchParams(document.location.search);
const myParam = urlParams.get('firstname');
console.log(myParam) //undefined
</script>
</body>
</html>
我想从 iframe URL 参数中获取名字
我没有定义
这里有什么问题?
【问题讨论】:
-
这能回答你的问题吗? stackoverflow.com/a/28296334/13983399
-
网址没有搜索参数
-
@Musa 你是什么意思?
-
https://on.co/onboarding/没有名字参数,它根本没有参数 -
好的,我更改了如何从 iframe 获取属性
标签: javascript html jquery dom iframe