Change flash src with jquery?

后端 未结 2 1552
悲哀的现实
悲哀的现实 2021-01-13 06:10

Hi I have a flash menu showing a few links, but when the user is logged in I want to change the menu from menu1 to menu2 ... so that it will display \"My Account\" rather th

相关标签:
2条回答
  • 2021-01-13 06:17

    If loggedin() is a load-time check done on the server-side, why not simply change the output from PHP?

    <div id="menu"> 
        <?php if (loggedin()) { ?>
            <object ...> ...
                <param name="movie" value="menu2.swf" /> ...
            </object>
        <?php } else { ?>
            <object ...> ...
                <param name="movie" value="menu1.swf" /> ...
            </object>
        <?php } ?>
    </div>
    

    If you really must do it from script then yes, you should create a new Flash object (by innerHTML or DOM methods, or getting a script like SWFObject to do it for you). Changing the source of a plugin object is not something you can do reliably cross-browser (especially IE).

    It might be better to include both menus on the page and just use display to hide one of them.

    It would almost certainly be better not to use Flash menus, which tend to be a usability, accessibility and SEO disaster. You've got a lot of animation possibilities built into jQuery and HTML5/CSS3/etc is increasingly capable of pretty effects. Flash menus are so 2003.

    0 讨论(0)
  • 2021-01-13 06:37

    Use .attr():

    $(document).ready(function() {
        $("#menu > object > embed").attr("src", "new link");
    });
    
    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题