2010-07-26 3 views
2

J'essaie d'ajouter le lecteur VLC dans une page html via jquery. Je peux le faire avec $ ("body"). Append (html), mais pas $ ("# VideoPlayer"). Append (html) ... Ce HTML est-il trop complexe?jquery.append ne fonctionne pas pour div avec id, mais travaille pour le corps?

jQuery:..

$("body").append("<object classid=\"clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921\" codebase=\"http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab\" width=\"1280\" height=\"720\" id=\"vlc\" events=\"true\">" + 
     "<param name=\"src\" value=\"rtsp://myStreamingStuff\"/>" + 
     "<param name=\"showdisplay\" value=\"true\"/>" + 
     "<param name=\"autoloop\" value=\"no\"/>" + 
     "<param name=\"autoplay\" value=\"true\"/>" + 
     "<embed type=\"application/x-google-vlc-plugin\" name=\"vlcfirefox\" autoplay=\"true\" loop=\"no\" width=\"1280\" height=\"720\" src=\"rtsp://myStreamingStuff\"></embed></object>" 
    ); 

Html

<body> 
    <div id="VideoPlayer"> 

    </div> 
</body> 

J'ai aussi essayé $ ("# VideoPlayer") html (html) et $ ("# VideoPlayer") ajouter (html) ainsi sans chance.

Répondre

1

Ahh J'ai trouvé mon problème.

je devais envelopper .append (html) appeler la fonction onload jquery comme ceci:

$(function() { 
$("#VideoPlayer").append("<object classid=\"clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921\" codebase=\"http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab\" width=\"1280\" height=\"720\" id=\"vlc\" events=\"true\">" + 
    "<param name=\"src\" value=\"rtsp://myStreamingStuff\"/>" + 
    "<param name=\"showdisplay\" value=\"true\"/>" + 
    "<param name=\"autoloop\" value=\"no\"/>" + 
    "<param name=\"autoplay\" value=\"true\"/>" + 
    "<embed type=\"application/x-google-vlc-plugin\" name=\"vlcfirefox\" autoplay=\"true\" loop=\"no\" width=\"1280\" height=\"720\" src=\"rtsp://myStreamingStuff\"></embed></object>" 
); 
}); 
Questions connexes