简体   繁体   中英

Unable to document.write on this code

Which code do I need to fix? Thank!

document.write('
            var parameters =
                {   id: "1"
                ,   src: "<?php echo $source?>"
                ,   autoPlay: "false"
                ,   width: "638"
                ,   height: "400"
                ,   autoHideControlBar: "false"
                ,   controlBarPosition: "bottom"
                };

            swfobject.embedSWF
                ( "vcp.swf"
                , "player"
                , parameters["width"], parameters["height"]
                , "10"
                , {}
                , parameters
                , { allowFullScreen: "true" }
                , { name: "sMPlayback" }
                );
');

You can't have new-lines in a string like you have, the string you're passing to document.write() has them...but since you're in the page, just remove the document.write , so your result should just be this:

<script type="text/javascript">
        var parameters =
            {   id: "1"
            ,   src: "<?php echo $source?>"
            ,   autoPlay: "false"
            ,   width: "638"
            ,   height: "400"
            ,   autoHideControlBar: "false"
            ,   controlBarPosition: "bottom"
            };

        swfobject.embedSWF
            ( "vcp.swf"
            , "player"
            , parameters["width"], parameters["height"]
            , "10"
            , {}
            , parameters
            , { allowFullScreen: "true" }
            , { name: "sMPlayback" }
            );​​ 
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM