我这里有一个初学者的问题...
我是一个移动应用程序和桌面应用程序开发人员,所以我在HTML和JavaScript以及整个Web技术方面非常糟糕。我有一个非常简单的案例,但无法解决,所以请在这里帮助我
我有一个非常简单明了的 html 文件,这个文件有一个用于视频聊天 API 的 iFrame 或 JavaScript(我有两个选项(,我希望能够传递带有 URL 的参数,并且此参数应该是 iFrame 或 JavaScript 调用的一部分
这是原始的 html 代码:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Chat</title>
</head>
<body>
<iframe
src="https://tokbox.com/embed/embed/ot-embed.js?embedId=3ce25a03-f681-478d-9e4a-d7da94fd4945&room=DEFAULT_ROOM&iframe=true"
width="900px"
height="1400px"
scrolling="auto"
allow="microphone; camera"
></iframe>
</body>
</html>
html
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="script.js"></script>
<title>Chat</title>
</head>
<body>
</body>
</html>
脚本.js
var iFrameElement = document.createElement('iframe');
// this will grab the url and split by # assuming you're passing the intended url after #
// if the intended url is already in the address bar, simply use
// window.location.href
var url = window.location.href.split('#')[1]
// create the iframe element
iFrameElement.src =
url;
iFrameElement.width = "900px"
iFrameElement.height = "1400px"
iFrameElement.scrolling="auto"
iFrameElement.allow="microphone; camera"
// create a new div to append the iframe to
var newDiv = document.createElement('div')
newDiv.appendChild(iFrameElement)
// append the div to body
document.body.appendChild(newDiv)
希望这有帮助