所以我试图使用document.write将anohter脚本写入文档。这是我的函数代码:
function onSaveOk(streamName,streamDuration,userId,cameraName,micName,recorderId){
//alert("onSaveOk("+streamName+","+streamDuration+","+userId+","+cameraName+","+micName+")");
//the user pressed the [save] button inside the recorder and the save_video_to_db.XXX script returned save=ok
//recorderId: the recorderId sent via flash vars, to be used when there are many recorders on the same web page
$('#record').hide();
document.write('"<d"+"iv id=jwplayer>"
+ "<cen"+"ter>" +
"<d"+"iv id=mediaplayer>"+"</di"+"v>"+
"<scr"+"ipt type=text/javascript>
jwplayer('mediaplayer').setup({
'flashplayer': 'jwplayer/player.swf',
'id': 'playerID',
'width': '640',
'height': '580',
'provider': 'rtmp',
'streamer': 'rtmp://domain/recorder/_definst_',
'file': 'onSaveOk("+streamName+")'
}); " +
"</scr"+"ipt>"+
"</cen"+"ter>"
')
基本上发生的事情是,显示的显示器根本不显示。当我在我的函数中有这个时,由于某种原因,$('#record').hide();
不起作用......
答案 0 :(得分:1)
您应该直接使用jQuery附加<div>
,并正常调用该函数。
答案 1 :(得分:0)
解析完文档后,不要使用document.write()
,因为它会清除当前文档。相反,您需要以编程方式向文档中添加元素。
要在加载后将HTML添加到文档中,可以使用此javascript:
var player = document.createElement("div");
player.innerHTML = '<div id="mediaplayer"></div>';
player.id = "jwplayer";
document.body.appendChild(player); // you decide where to add it to your page
jwplayer('mediaplayer').setup({
'flashplayer': 'jwplayer/player.swf',
'id': 'playerID', // shouldn't this match one of the IDs in your HTML???
'width': '640',
'height': '580',
'provider': 'rtmp',
'streamer': 'rtmp://domain/recorder/_definst_',
'file': 'onSaveOk("+streamName+")'
});