你可以在HTML Object标签中使用document.writeln吗?

时间:2016-09-16 15:26:22

标签: javascript html vlc

我正在尝试通过URL将参数传递到在vlc对象中显示rtsp视频流的网页。该参数设置为VLC对象的“SRC”。第二个(使用显式URL工作正常)使用document.writeln的对象第一个对象不起作用。我在两个

之间放了相同的脚本代码
<script>document.write(getpar("IP"))</script>

并将页面称为......

page.html中IP = RTSP://10.61.197.119

并在HTML页面上的两个VLC对象之间显示“rtsp://10.61.197.119”,因此我知道我的javascript函数正常工作。我唯一可以假设的是对象不能很好地嵌入javascript ??

<html>
<body>
<script type="text/javascript">
function getpar(search_for) 
{
   var query = window.location.search.substring(1);
   var parms = query.split('&');
   for (var i = 0; i < parms.length; i++) 
   {
      var pos = parms[i].indexOf('=');
      if (pos > 0  && search_for == parms[i].substring(0,pos)) 
      {
         return parms[i].substring(pos+1);;
      }
   }
   return "";
}
</script>
<object
   classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
   codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab"
   width="1024" height="768"
   id="vlcPlayer1"
   name="vlcPlayer1"
   class="vlcPlayer"
   events="True">
   <param name="Src" value="<script>document.write(getpar("IP"))</script>" />
   <param name="AutoLoop" value="False" />
   <param name="AutoPlay" value="True" />
   <param name="controls" value="False" />
</object>

<script>document.write(getpar("IP"))</script>

<object
   classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921"
   codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab"
   width="1024" height="768"
   id="vlcPlayer"
   name="vlcPlayer2"
   class="vlcPlayer2"
   events="True">
   <param name="Src" value="rtsp://10.61.197.119" />
   <param name="AutoLoop" value="False" />
   <param name="AutoPlay" value="True" />
   <param name="controls" value="False" />
</object>


</body>
</html>

感谢您的帮助!

0 个答案:

没有答案