object, param, jquery

前端 未结 5 1153
隐瞒了意图╮
隐瞒了意图╮ 2020-12-01 15:33

    
    
             


        
                      
相关标签:
5条回答
  • 2020-12-01 15:51

    After searching for info, it seems you cannot dynamically change the param element's attributes dynamically. The simplest way will probably be to pull the element's HTML into a variable, feed that back into jQuery, and use CSS selectors on that. Then you could clear the object and replace it with the new code.

    var url = (url here);
    var code = $("#embedded").html();
    var newcode = $("param:first", code).attr("src", url).html();
    $("#embedded").html(newcode);
    

    or something like that... ;)

    0 讨论(0)
  • 2020-12-01 15:51

    I have a solution like this:

    var flashhtml = $("object").html();
    $('object').before("<div id='mydiv'>... div</div>");
    $('object').remove();
    var flashattr = 'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="583" height="297">';
    $('#mydiv').html('<object ' + flashattr + '<param name="wmode" value="transparent">' + flashhtml + '</object>');
    
    0 讨论(0)
  • 2020-12-01 15:52

    You should use the name of the variable where you have put the url:

    $('#pano param:first').val(urlconst)
    
    0 讨论(0)
  • 2020-12-01 16:01

    Have you considered using jQuery SWFObject plugin?

    http://jquery.thewikies.com/swfobject/

    0 讨论(0)
  • 2020-12-01 16:11

    EDIT

    The behavior I described below only takes place in IE in particular situations. When the object element was present in the loaded DOM, I could update the value for the param element named movie, but the state of the object didn't change. And the object can't be easily refreshed as far as I know. It looks like the best way is to remove the object element and add a fresh one. For that, it seems like the SWFObject jQuery plugin that SolutionYogi suggests, or something similar, might indeed be the best way to go.

    ORIGINAL

    From what I see when I try this out in IE8, IE retains only the embed elements as the page is loaded, not the object and param elements. So you can't change that value of the param because it no longer exists.

    So if this gets served:

    <object width="425" height="344">
        <param name="movie" 
            value="http://www.youtube.com/v/ePXlkqkFH6s&hl=en&fs=1&"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed src="http://www.youtube.com/v/ePXlkqkFH6s&hl=en&fs=1&" 
            type="application/x-shockwave-flash"
            allowscriptaccess="always" 
            allowfullscreen="true" 
            width="425" height="344"></embed>
    </object>
    

    It becomes only this in the IE DOM:

    <embed src="http://www.youtube.com/v/ePXlkqkFH6s&hl=en&fs=1&" 
        type="application/x-shockwave-flash"
        allowscriptaccess="always" 
        allowfullscreen="true" 
        width="425" height="344"></embed>
    

    To get a movie to update in IE, I had to cause IE to reparse the HTML for embed. The following seemed to work:

    var placeHolder = $("<div />");
    var tempParent = $("<div />");
    var embed = $("#movieparent embed");
    embed.replaceWith(placeHolder);
    tempParent.append(embed);
    embed.attr("src", newSrcUrl);
    placeHolder.replaceWith(tempParent.html());
    
    0 讨论(0)
提交回复
热议问题