<script type="text/javascript">
//<![CDATA[
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var video = getUrlVars()["v"];
var width=getUrlVars()["w"];
var height=getUrlVars()["h"];
document.write('<iframe src="https:xxx.com?id='+video+'" id="iframe" width="'+width+'" height="'+height+'" Scrolling="no" height="+height+"></iframe>');
//]]>
</script>
在上面的代码中我想添加window.onresie事件如果我添加一个功能它不起作用请帮帮我。
答案 0 :(得分:0)
使用以下简单的内容:
您可以将此JS合并到当前代码中,如下所示:
<script type="text/javascript">
//<![CDATA[
function myFunction() {
var w = window.outerWidth;
var h = window.outerHeight;
var txt = "Window size: width=" + w + ", height=" + h;
document.getElementById("demo").innerHTML = txt;
}
function getUrlVars() {
var vars = {};
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
vars[key] = value;
});
return vars;
}
var video = getUrlVars()["v"];
var width=getUrlVars()["w"];
var height=getUrlVars()["h"];
document.write('<iframe src="https:xxx.com?id='+video+'" id="iframe" width="'+width+'" height="'+height+'" Scrolling="no" height="+height+"></iframe>');
//]]>
</script>
希望这有帮助!