Only accessible id right now is "dialog1". Given that information how do I traverse down to get the <object classid>
?
I just realised that i've to do this with Mootools as the rest of the script is written in it. I'm completely new to Mootools thou'
$('#dialog1').children('NOLOCALIZATION').children('object').attr('classid'); seems to work for me. I'm actually using MooTools. How do I use this jQuery without conflicting?
<ul>
<li>
<a href="#dialog1" rel="vidbox" title="video">watch video</a>
</li>
</ul>
<div id="dialog1" class="window dialog" style="width: 806px; height:504px;">
<NOLOCALIZATION>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="806" height="504" id="http://www.youtube.com/watch?v=uhi5x7V3WXE">
<param name="wmode" value="transparent" />
<param name="movie" value="http://www.youtube.com/watch?v=uhi5x7V3WXE" /开发者_开发问答>
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="FlashVars" value="width=806&height=504&dart_zone_url=&cms_id=AllBusiness&content_id=16009601&auto_start=1&auto_mute=1&playPreroll=0&playtremor=0"/>
<object type="application/x-shockwave-flash" width="806" height="504" data="http://www.youtube.com/watch?v=uhi5x7V3WXE">
<param name="wmode" value="transparent" />
<param name="movie" value="http://www.youtube.com/watch?v=uhi5x7V3WXE" />
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always" />
<param name="FlashVars" value="width=806&height=504&dart_zone_url=&auto_start=1&auto_mute=1&playPreroll=0&playtremor=0"/>
</object>
</object>
</NOLOCALIZATION>
</div>
var classid = $('#dialog1 object').first().attr('classid');
or i suppose:
$('#dialog1 object:not(object object)')
or
$('#dialog1 > nolocalization > object')
although I'm not sure how the browser handles a <NOLOCALIZATION>
element.
After your comment about needing a dynamic version:
$(dialog).find('object').first().attr('classid');
Although really you just need to read through the jQuery API and be creative with your selectors. Test things out; see what works; see what doesn't.
for mootools:
document.getElements("a[rel=vidbox]").addEvents({
click: function(e) {
e.stop();
var div = this.get("href").replace("#", "");
var obj = $(div).getElement("object");
// object may not be extended so normal getAttribute.
var attr = obj.getAttribute("classid");
alert(attr);
}
});
http://jsfiddle.net/dimitar/XUyDU/
notice that in IE6-IE8, mootools does NOT extend the OBJECT element, hence obj will NOT have the otherwise available .get()
or any other Element.proto that mootools adds.
精彩评论