我在这里有一个初学者的问题...
我是移动应用程序和台式机应用程序开发人员,所以我在HTML和JavaScript以及整个网络技术方面表现不佳。我有一个非常简单的案例,但无法解决,请在这里帮助我
我有一个非常简单明了的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>
script.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)
希望这会有所帮助