I want to load some jQuery code before the DOM is ready. I want to make a flash file transparant as the DOM loads. I was going to use something like this but Flash is initilized before the DOM loads.
jQuery(document).ready(function(){
jQuery('object:not(:has(wmode))').each(function(){
jQuery(this).attr('wmode', 'transparent');
jQuery(this).prepend('<param name="wmode" value="transparent">');
jQuery(this).children('embed').attr('wmode', 'transparent');
});
});
Any ideas on how to do this?
EDIT
Hey guys, thanks for the help, Basically, The flash content is ing from our Advertisement Manager, which stupidly enough, doesn't allow direct editing of the HTML, as to add the required wmode attributed into the specific tags...
So Javascript is my only option...
I want to load some jQuery code before the DOM is ready. I want to make a flash file transparant as the DOM loads. I was going to use something like this but Flash is initilized before the DOM loads.
jQuery(document).ready(function(){
jQuery('object:not(:has(wmode))').each(function(){
jQuery(this).attr('wmode', 'transparent');
jQuery(this).prepend('<param name="wmode" value="transparent">');
jQuery(this).children('embed').attr('wmode', 'transparent');
});
});
Any ideas on how to do this?
EDIT
Hey guys, thanks for the help, Basically, The flash content is ing from our Advertisement Manager, which stupidly enough, doesn't allow direct editing of the HTML, as to add the required wmode attributed into the specific tags...
So Javascript is my only option...
Share Improve this question edited Sep 26, 2012 at 10:28 Thariama 50.9k13 gold badges145 silver badges175 bronze badges asked Nov 8, 2010 at 14:31 DarkMantisDarkMantis 11 silver badge4 bronze badges 4- 6 so you want to manipulate the DOM before the DOM loads? – hunter Commented Nov 8, 2010 at 14:33
- Yeah that's correct. Is there any way? – DarkMantis Commented Nov 8, 2010 at 14:35
- what Hunter means is how can you manipulate something that isnt loaded? if you want the flash to be edited you'll have to do it in the HTML itself. later you can edit it with jquery to be 'normal' – Stefanvds Commented Nov 8, 2010 at 14:43
-
Hmm, difficult. Not sure whether
wmode
can be set afterwards at all without re-creating the whole Flash movie. That would be worth a separate question IMO, what you are asking here is a paradox in itself – Pekka Commented Nov 8, 2010 at 16:00
3 Answers
Reset to default 3ready()
is the earliest point at which you can safely access arbitrary DOM elements.
You could put a script
block directly after you declare the object
tag: That should work, you will have access to the object
element.
However, I don't think even that will help you: As far as I know, Flash won't accept a JavaScript-side changing of the wmode
parameter anyway.
You would have to put wmode.transparent
into the HTML, or create the Flash movies dynamically when the DOM is loaded.
Using javascript before the dom is loaded will yield to unpredictable results. Modify your html code as you wish, but do not use javascript.
The safest way is to construct the object or embed element on dom ready event:
<div id="flash"></div>
$(document).ready(function(){
var htm= '<object ...><param name="some" value="val" ... /></object>';
$('#flash').html(htm);
});
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745351642a4623867.html
评论列表(0条)