Jquery MultiZoom插件未在页面加载时加载

时间:2013-04-12 12:31:13

标签: javascript jquery jquery-plugins

我遇到了jQuery multizoom插件的问题。 document.ready()window.load()不会在主要功能上启动它。在页面加载

  • div(#slide_body)从左向右滑出。
  • 然后在这个div(#slide_body)里面我在PIctures上调用jQuery插件Multizoom。
  • 由于slide_body,jQuery multizoom未加载。我尝试了document.read()window.load(),但插件无法启动。
  • 如果我调整网页大小(Ctrl +鼠标滚轮),那么它会重新定位页面元素,然后开始工作。
  • 或者如果我点击拇指图像,那么它就开始工作了。但第一张图片永远不会在页面加载上运行。

请指导如何在页面加载时第一次加载。除了Document.ready()或window.load()

之外的任何其他事件

由于

<script>
function slid_body(){
    document.getElementById('slid_body').style.left = "0px";
    //document.getElementById('slid_body').style.width = "804px";
}
function slideIn() {
    //document.getElementById('slid_body').style.left = "0px";

    document.getElementById('slid_body').style.left = "-804px";
}
</script>
<body onload="javascript:slid_body()">   
 <div id="slid_body_out">
            <div id="slid_body">
                <div id="heading">
                    <ul id="breadcrumbs">
                        <li>Collection</li>
                        <li>
                            Casual</li>
                      </ul>
                <div id="left">
                    <div id="prodetail">
                        <div id="pro_dtl_left">
                            <div id="pro_dtl_leftimg">

                                <div class='targetarea'><img id='multizoom1' src='images/ProductImages/Medium/634981200372366040_XGN_6539.JPG' alt='zoomable'L32840'></img></div>
                            </div>
                            <div id="pro_dtl_right_moreviews">
                                <p>
                                    Scroll on above image to view enlarged picture<br />
                                    Use Mouse Scroll to Zoom in/out.
                                </p>
                                <li>More Views</li>
                                <br />
                                <span id="ctl00_ContentPlaceHolder1_litThumbs" style="display:inline-block;width:300px;"><ul><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634981200372366040_XGN_6539.JPG'  data-large='images/ProductImages/Original/634981200372366040_XGN_6539.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634981200372366040_XGN_6539.JPG' alt='L32840' /></a></li><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634982980662846576_XGN_6537.JPG'  data-large='images/ProductImages/Original/634982980662846576_XGN_6537.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634982980662846576_XGN_6537.JPG' alt='L32840' /></a></li><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634982981340675266_XGN_6540.JPG'  data-large='images/ProductImages/Original/634982981340675266_XGN_6540.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634982981340675266_XGN_6540.JPG' alt='L32840' /></a></li><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634982981855793870_XGN_6538.JPG'  data-large='images/ProductImages/Original/634982981855793870_XGN_6538.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634982981855793870_XGN_6538.JPG' alt='L32840' /></a></li></ul></span>
                            </div>
                        </div>


            </div>
        </div>
        <script type="text/javascript">
            jQuery(document).ready(function ($) {

                $('#multizoom1').addimagezoom({
                    descArea: '#description',
                    speed: 1000,
                    descpos: true,
                    imagevertcenter: true,
                    magvertcenter: true,
                    zoomrange: [3, 10],
                    magnifiersize: [500, 450],
                    magnifierpos: right,
                    cursorshadecolor: '#5C2E91',
                    cursorshade: true
                });

            })

        </script>
</body>

1 个答案:

答案 0 :(得分:0)

可能是body onload="javascript:slid_body()"$(document).ready jQuery函数发生冲突。

试试这个,将脚本放在一个地方:

<body>   
 <div id="slid_body_out">
            <div id="slid_body">
                <div id="heading">
                    <ul id="breadcrumbs">
                        <li>Collection</li>
                        <li>
                            Casual</li>
                      </ul>
                <div id="left">
                    <div id="prodetail">
                        <div id="pro_dtl_left">
                            <div id="pro_dtl_leftimg">

                                <div class='targetarea'><img id='multizoom1' src='images/ProductImages/Medium/634981200372366040_XGN_6539.JPG' alt='zoomable'L32840'></img></div>
                            </div>
                            <div id="pro_dtl_right_moreviews">
                                <p>
                                    Scroll on above image to view enlarged picture<br />
                                    Use Mouse Scroll to Zoom in/out.
                                </p>
                                <li>More Views</li>
                                <br />
                                <span id="ctl00_ContentPlaceHolder1_litThumbs" style="display:inline-block;width:300px;"><ul><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634981200372366040_XGN_6539.JPG'  data-large='images/ProductImages/Original/634981200372366040_XGN_6539.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634981200372366040_XGN_6539.JPG' alt='L32840' /></a></li><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634982980662846576_XGN_6537.JPG'  data-large='images/ProductImages/Original/634982980662846576_XGN_6537.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634982980662846576_XGN_6537.JPG' alt='L32840' /></a></li><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634982981340675266_XGN_6540.JPG'  data-large='images/ProductImages/Original/634982981340675266_XGN_6540.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634982981340675266_XGN_6540.JPG' alt='L32840' /></a></li><li class='multizoom1 thumbs'><a href='images/ProductImages/Medium/634982981855793870_XGN_6538.JPG'  data-large='images/ProductImages/Original/634982981855793870_XGN_6538.JPG' data-title='L32840'><img src='images/ProductImages/thumb/634982981855793870_XGN_6538.JPG' alt='L32840' /></a></li></ul></span>
                            </div>
                        </div>
            </div>
        </div>
        <script type="text/javascript">
            $(document).ready(function() {

                $('#multizoom1').addimagezoom({
                    descArea: '#description',
                    speed: 1000,
                    descpos: true,
                    imagevertcenter: true,
                    magvertcenter: true,
                    zoomrange: [3, 10],
                    magnifiersize: [500, 450],
                    magnifierpos: right,
                    cursorshadecolor: '#5C2E91',
                    cursorshade: true
                });

                function slid_body(){
                     document.getElementById('slid_body').style.left = "0px";
                }
                function slideIn() {    
                     document.getElementById('slid_body').style.left = "-804px";
                }

                slid_body();
            })

        </script>
</body>