Re: [問題] javascript 取得播放影片長度

看板Ajax作者 (骨頭)時間17年前 (2008/03/18 22:01), 編輯推噓0(113)
留言5則, 2人參與, 最新討論串2/2 (看更多)
※ 引述《buganini (霸格尼尼)》之銘言: : ※ 引述《hera1016 ()》之銘言: : : 可是如果我是在html裡面embed object就不會有這個問題 囧a : 因為... : '='會覆蓋整個innerHTML : 並非append : 應該先拿一個字串裝好全部的html再一口氣塞進去 : 也不要分次用+= : 因為可能你放前面一段的時候會造成html parse錯誤 : 流程就中斷了 : 沒加</object>可以放是因為 : innerHTML的內容是<embed>那行 附議bug的說法,另外提供個人比較喜歡用的字串組裝處理法。 先用array裝起來 然後再用join一次組合起來 會比分次的字串+=省時省力 var objStr=[]; objStr.push( "<object id='MediaPlayer' width=544 height=432"); objStr.push( "classid='CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95'"); objStr.push("standby='Loading Windows Media Player components…'"); objStr.push( "type='application/x-oleobject'"); objStr.push("codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112'>"); objStr.push("<param name='filename' value='magic.wmv'>"); objStr.push("<param name='autoStart' value='True'>"); objStr.push("<embed type='application/x-mplayer2' src='magic.wmv' ); objStr.push("name='MediaPlayer' width=544 height=432></embed>"); show_file.innerHTML = objStr.join(""); -- I am a person, and I am always thinking . Thinking in love , Thinking in life , Thinking in why , Thinking in worth. I can't believe any of what , I am just thinking then thinking , but worst of all , most of mine is thinking not actioning... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 125.232.4.89

03/18 22:34, , 1F
這種方式效率也比較好..雖然是幾百ms的差距XD
03/18 22:34, 1F

03/20 11:32, , 2F
效能要更好的話應該不要用push
03/20 11:32, 2F

03/20 11:32, , 3F
改成用objStr[objStr.length]='123'
03/20 11:32, 3F

03/20 11:32, , 4F
抱歉 按錯了 按到噓 等下推回來
03/20 11:32, 4F

03/20 11:36, , 5F
推 :p
03/20 11:36, 5F
文章代碼(AID): #17tyjF5C (Ajax)
文章代碼(AID): #17tyjF5C (Ajax)