script let iframeObj = documentgetElementByIdWANG; iframeObjaddEventListenerload = iframeObjcontentWindowpostMessage id$objvod_id name$objvod_name-$objvod_play_lis
在给定的代码中,有几处错误:
<script>标签应该放在HTML文件的<head>或<body>标签中。document.getElementById("WANG")的参数应该是一个有效的元素ID,而不是"WANG"。{$obj.vod_id}、{$obj.vod_name}、{$obj['vod_play_list'][$param['sid']]['urls'][$param['nid']]['name']}、{$GLOBALS['_COOKIE']['group_name']}、{$obj.player_info.url_next}、{$param.sid}、{$param.nid}和{$obj.player_info.url}应该是服务器端的变量或者从其他地方获取的变量,而不是在JavaScript代码中直接使用的。postMessage方法中的第一个参数应该是一个对象,而不是一个字符串。
修正后的代码如下:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
</head>
<body>
<iframe id="iframeObj" src="https://www.example.com"></iframe>
<script>
window.addEventListener('load', () => {
let iframeObj = document.getElementById("iframeObj");
iframeObj.addEventListener('load', () => {
iframeObj.contentWindow.postMessage({
id: "123",
name: "Test",
group: "Group",
next: "https://www.example.com/next",
sid: "456",
nid: "789",
api: "https://www.suying.lol/index.php",
dmId: "https://www.example.com/dm"
}, "*");
});
});
</script>
</body>
</html>
请注意,上述代码仅供参考,你需要根据实际情况进行适当修改
原文地址: https://www.cveoy.top/t/topic/hUCv 著作权归作者所有。请勿转载和采集!