1

I have a system loading in a youtube video using an object tag with the id="cstmVideoContent" and the data=(youtube link). I need to extract the content in the object's data property using javascript/jquery and render it elsewhere on the page.

Here's my relevant html:

<object id="cstmVideoContent" width="400" height="320" type="application/x-shockwave-flash" data="NEED THE VIDEO LINK THAT IS HERE" style="visibility: visible;"></object>

Based on my admittedly crude knowledge of javascript/jquery, it seems like this should work:

var videolink = $('object#cstmVideoContent').attr('data');

But it is coming back as "undefined" every time. Is this method possible, am I doing something wrong, or is there a better way? Thanks!


hammer.js http://eightmedia.github.com/hammer.js/ is one of the best javascript library for such problems..

4

1 回答 1

3

这就是我为数据所做的:

<object id="cstmVideoContent" width="400" height="320" type="application/x-shockwave-flash" data-link="NEED THE VIDEO LINK THAT IS HERE" style="visibility: visible;"></object>

var personalvideo = $('#cstmVideoContent').data('link');

这是基于 HTML5 的,因此您需要考虑在多个浏览器中进行测试以确保兼容性。

见:http ://api.jquery.com/data/

于 2013-03-14T16:18:56.867 回答