我想显示包含YouTube视频的弹出窗口。我的问题是当用户调整弹出窗口的大小时如何调整YouTube播放器的大小?
弹出窗口的头部分PHP / HTML代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Wavin Video</title>
<script src="jquery-1.4.1.min.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
//If the User resizes the window
//$(window).bind("resize", resizeWindow);
$(window).resize(resizeWindow).resize()
function resizeWindow( e ) {
var target = "#youtubebox2";
var newWindowHeight = $(window).height();
var newWindowWidth = $(window).width();
console.log("Width : "+newWindowWidth);
console.log("Height: "+newWindowHeight);
console.log("---------");
$(target).html("<object width=\""+newWindowWidth+"\" height=\""+newWindowHeight+"\" id=\"youtubebox\"><param name=\"movie\" value=\"http://www.youtube.com/v/<?php echo $_GET['filename'];?>\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/<?php echo $_GET['filename'];?>\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\""+newWindowWidth+"\" height=\""+newWindowHeight+"\"></embed></object>");
}
});
</script>
</head>
<body>
<div align="center" style="padding:6px 0px 0px 0px;background-color: #ccc;" id="youtubebox2">
<object width="480" height="385" id="youtubebox">
<param name="movie" value="http://www.youtube.com/v/<?php echo $_GET['filename'];?>"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/<?php echo $_GET['filename'];?>" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385">
</embed>
</object>
</div>
</body>
</html>
该页面通过$ _GET变量接收youtube视频ID。
上面的代码不起作用,YouTUbe Player的大小未调整。有什么我想念的吗?
参考方案
仍然,为什么要重写整个对象html而不是更新对象的高度/宽度?
$("object, embed").height($(window).height());
$("object, embed").width($(window).width());
再三考虑,为什么不将高度/宽度设置为100%?
Div单击与单选按钮相同吗? - php有没有一种方法可以使div上的click事件与表单环境中的单选按钮相同?我只希望下面的div提交值,单选按钮很丑代码输出如下:<input id="radio-2011-06-08" value="2011-06-08" type="radio" name="radio_date…
使用Ajax呈现html表 - php我想知道如何实现以下项目其实我有一个php代码,可以渲染一张桌子<table id = "oldata" class ="table table-bordered"> <thead> <tr class ="success"> <th class="…
提交表单后显示模式对话框 - php提交下载文件后,我有一张表格。我要自动而不是自动下载文件..以显示模态对话框并显示下载链接。<form name="softwareform" id="softwareform" action="../downloadlink.php" method="POST" alig…
使用XPath在PHP中提取XML - php我有以下XML:<root> <level name="level1"> <!-- More children <level> --> </level> <level name="level2"> <!-- Some more childre…
下一个jQuery不起作用,我的代码为真 - php我的jQuery代码不起作用,我找不到原因。该代码似乎还可以。我的html代码<html> <head> <title>Learning Jquery</title> <link rel="stylesheet" type="text/css" href="…