我正在加载一个 html 页面,其中 kaltura 播放器使用 jquery.load() 在 jquery 中嵌入代码。想法是通过页面上的javascript加载div标签中的视频。
aspx 页面中的代码
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!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 id="Head1" runat="server"></head>
<body>
<script src="images/jquery-1.9.1.min.js" type="text/javascript"> </script>
<script type="text/javascript">
function test() {
var light = document.createElement('div');
light.id = "light";
document.body.appendChild(light);
$("#light").load("files/test.html");
$("#fade").fadeIn();
$("#light").fadeIn(1000);
$("#close").fadeIn();
return false;
}
</script>
<form id="form1" runat="server">
<asp:LinkButton ID="lb" runat="server" ClientIDMode="AutoID" Text="test" ></asp:LinkButton>
</form>
</body>
</html>
测试.html 文件
<html>
<body>
<script src="http://www.kaltura.com/p/423851/sp/42385100/embedIframeJs/uiconf_id/11598752/partner_id/423851"></script>
<div id="kaltura_player" style="width: px; height: px;"></div>
<script>
kWidget.embed({
"targetId": "kaltura_player",
"wid": "_423851",
"uiconf_id": "11598752",
"flashvars": {},
"entry_id": "1_znvt6hgh"
});
</script>
</body>
</html>
从 aspx.cs 文件调用函数 test()
protected void Page_Load(object sender, EventArgs e)
{
lb.OnClientClick = "return test()";
}
当我单击按钮在 div 中加载 kaltura 视频时出错(id='light')
Microsoft JScript 运行时错误:“kWidget”未定义
如果我们需要包含任何文件或 api 来克服此错误,请告诉我。谢谢。