iframe通过url方式来获传递的参数
- 一、src="http://xxxx/#/policyOverview?code=aaaa"
- 二、 src="/static/iframePhone/html/main.html?code=aaaa"
一、src=“http://xxxx/#/policyOverview?code=aaaa”
<iframedata-v-47a50536=""src="http://xxxxx/#/policyOverview?code=aaaa"frameborder="0"allowfullscreen=""style="width: 100%; height: 100%"></iframe><iframedata-v-47a50536=""src="http://xxxxxx?appId=1803674938150752257&code=bbbb"frameborder="0"allowfullscreen=""style="width: 100%; height: 100%"></iframe>
window.addEventListener('DOMContentLoaded', () => {console.log(window.location.href, '1111111');console.log(window.frames.location.href, '222222');console.log(window.self.location.href, '3333333');});
二、 src=“/static/iframePhone/html/main.html?code=aaaa”
<iframeid="iframeContainer"src="/static/iframePhone/html/main.html?code=aaaa"style="width: 600px; height: 80px"></iframe>
setTimeout(() => {const urlParams = new URLSearchParams(window.location.search);console.log(urlParams, 'urlParams');const codeValue = urlParams.get('code');console.log('获取到的code值为:', codeValue);}, 3000);
