为什么这个jquery窗口不工作?

时间:2011-06-28 14:10:25

标签: javascript jquery

我正试图让它运行:http://fstoke.me/jquery/window/示例2具体

我的代码:

<html>

    <head>
    <title>Example of Windows</title>
    <link rel="stylesheet" type="text/css" href="window.css" />
    <script type="text/javascript" src="jquery.js"> </script>
    <script type="text/javascript" src="window.js"> </script>
    </head>

    <body>
    <script type='text/javascript'>
    $.window({
   showModal: true,
   modalOpacity: 0.5,
   icon: "http://www.fstoke.me/favicon.ico",
   title: "Professional JavaScript for Web Developers",
   content: $("#window_block2").html(), // load window_block2 html content
   footerContent: "<img style="vertical-align:middle;" src="img/star.png"> This is a nice plugin :^)";
});
    </script>


    <div id="example2" class='example_block'> 
            <h3>Demo</h3> 
            <div class='demo'> 
                <div id='window_block2' style='display:none;'> 
                    <div style='padding:10px;'> 
                        <div style='font-size:24px; font-weight:bold; margin-bottom:10px; color:#44aaff;'>Introduction</div> 
                        <img style='border:0; float:left; margin:10px;' src='http://lh5.ggpht.com/_W-5oCUN3-sQ/TNUfmAY_mFI/AAAAAAAADwc/Dav33v1iBlY/s144/Professional%20JavaScript%20for%20Web%20Developers.jpg'/> 
                        <div> 
                            If you want to achieve JavaScript's full potential, it is critical to understand its nature, history, and limitations. 
                            This book sets the stage by covering JavaScript from its very beginning to the present-day incarnations that include 
                            support for the DOM and Ajax. It also shows you how to extend this powerful language to meet specific needs and create
                            seamless client-server communication without intermediaries such as Java or hidden frames.
                        </div> 
                    </div> 
                </div> 
                <input type='button' value='Click Here to Create Window' onclick='createWindowWithHtml();'/> 
            </div> 
        </div> 

    </body>

</html>

错误:当我点击按钮时,它什么也没做!有人在这看到任何问题?我觉得它可能与嵌入式脚本有关。

页面现在加载...就像这样看起来好像它在你上载时触发了事件,而不是当你点击按钮时这里出了问题? img

有人吗?!

1 个答案:

答案 0 :(得分:2)

如果那个文字正是你所拥有的那么你可能无法做到这一点......

"<img style="vertical-align:middle;" src="img/star.png"> This is a nice plugin :^)";

你很可能需要这个......

footerContent: "<img style='vertical-align:middle;' src='img/star.png'> This is a nice plugin :^)"

你最后不需要分号......或者至少不应该

编辑:

function createWindowWithHtml() {
    $.window({
        showModal: true,
        modalOpacity: 0.5,
        icon: "http://www.fstoke.me/favicon.ico",
        title: "Professional JavaScript for Web Developers",
        content: $("#window_block2").html(), // load window_block2 html content
        footerContent: "<img style='vertical-align:middle;' src='img/star.png'> This is a nice plugin :^)"
    });
}