English 中文(简体)
jquery.tinyscrollbar 弹出滚动条不工作
原标题:jquery.tinyscrollbar pop-up scroll bar not working

请单击“ 全部看到”, 然后显示一个弹出。 弹出时会出现, 但滚动条没有工作 。

< 强力 > JavaScript < /强 >

$(document).ready(function(){
    $( #scrollbar1 ).tinyscrollbar();    
});

//SETTING UP OUR POPUP
//0 means disabled; 1 means enabled;
var popupStatus = 0;

//loading popup with jQuery magic!
function loadPopup(){
    //loads popup only if it is disabled
    if(popupStatus==0){
        jQuery("#backgroundPopup").css({
            "opacity": "0.7"
        });
        jQuery("#backgroundPopup").fadeIn("slow");
        jQuery("#popupContact").fadeIn("slow");
        popupStatus = 1;
    }
}

//disabling popup with jQuery magic!
function disablePopup(){
    //disables popup only if it is enabled
    if(popupStatus==1){
        jQuery("#backgroundPopup").fadeOut("slow");
        jQuery("#popupContact").fadeOut("slow");
        popupStatus = 0;
    }
}

//centering popup
function centerPopup(){
    //request data for centering
    var windowWidth = document.documentElement.clientWidth;
    var windowHeight = document.documentElement.clientHeight;
    var popupHeight = jQuery("#popupContact").height();
    var popupWidth = jQuery("#popupContact").width();
    //centering
    jQuery("#popupContact").css({
        "position": "absolute",
        "top": windowHeight/2-popupHeight/2,
        "left": windowWidth/2-popupWidth/2
    });
    //only need force for IE6

    jQuery("#backgroundPopup").css({
        "height": windowHeight
    });

}


//CONTROLLING EVENTS IN jQuery
jQuery(document).ready(function(){
    //LOADING POPUP
    //Click the button event!
    jQuery("#button").click(function(){
        //centering with css
        centerPopup();
        //load popup
        loadPopup();
    });

    //CLOSING POPUP
    //Click the x event!
    jQuery("#popupContactClose").click(function(){
        disablePopup();
    });
    //Click out event!
    jQuery("#backgroundPopup").click(function(){
        none();
    });
    //Press Escape event!
    jQuery(document).keypress(function(e){
        if(e.keyCode==27 && popupStatus==1){
            disablePopup();
        }
    });

});

function LoadPop(){
        centerPopup();
        loadPopup();
}

< 强 > HTML

<div class="achieve">
    <h2><a href="#" id="button">(see all)</a></h2>
    <div class="achieve-container">

    </div>
</div>
<div id="popupContact">
    <div class="" id="contactArea">
            <div class="logbox">
                <div id="scrollbar1">
                <div class="scrollbar"><div class="track"><div class="thumb"><div class="end"></div></div></div></div>
                <div class="viewport">
                <div class="more-achive">
                    <h2>My Profile <a id="popupContactClose"><img src="images/close.gif" /></a></h2>
                    <div class="spacer"></div>
                    <div class="profstat">
                        <img src="images/pro-image1.gif" alt="Profile Image" />
                        <h1>Emily Hsiung</h1>
                        <p><span>567</span> Points</p>
                        <p><span>22</span> achievements</p>
                    </div>
                    <div class="proflevelindicator">
                        <img src="images/level-indicator.gif" alt="level indicator" />
                        <h1>Level 5 Elephant Hunter</h1>
                        <p><span>33</span> Points to next level</p>
                    </div>
                    <div class="spacer"></div>
                    <div class="achievelist">
                        <h2>Achievements</h2>
                        <ul>
                            <li>
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Spotlight</div>
                            </li>
                            <li>
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">15 Minutes of Fame</div>
                            </li>
                            <li>
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Contributor</div>
                            </li>
                            <li class="nomar">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Super Contributor</div>
                            </li>
                            <li class="nomar1">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Share Your Toughts</div>
                            </li>
                            <li class="nomar1">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">shout From The Rooftops</div>
                            </li>
                            <li class="nomar1">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">15 Minutes of Fame</div>
                            </li>
                            <li class="nomar">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Super Contributor</div>
                            </li>
                            <li class="nomar1">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Share Your Toughts</div>
                            </li>
                            <li class="nomar1">
                                <div class="imagbox"><img src="images/ach6.gif" /></div>
                                <div class="titlebox">shout From The Rooftops</div>
                            </li>
                            <li class="nomar1">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">15 Minutes of Fame</div>
                            </li>
                            <li style="margin:0 0 0 0;">
                                <div class="imagbox"><img src="https://encrypted-tbn0.google.com/images?q=tbn:ANd9GcQB1T4_bghGtisR6Tom0Umf3FZHCQoPGFJgD0Orck3cB0F8iTZN" /></div>
                                <div class="titlebox">Contributor</div>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="spacer"></div>
            </div>
        </div>
    </div>
</div>
<div class="spacer"></div>
</div>
<div id="backgroundPopup"></div>
最佳回答

JavaScript 错误为 Uncaught TypeError: 无法在 jquery.tinyscrollbar.js:54 上读取未定义 的属性滚动8: .tinyscrollbar.js:54 。 查看 http://www.baijs.nl/tinyscrollbar/js/jquery.tinyscrollbar.js> > 源 ,它试图查找 passH8

oContent[options.axis] = oContent.obj[0][ scroll + sSize];

但“内容”的定义是:

var oContent = { obj: $( .overview , root) };

您的标记中没有包含 class=" overview" 的元素, 因此脚本失败 。

我建议按照网站的例子,您似乎有“http://www.baijs.nl/tinyscrollbar/> 下载了 的脚本, 特别是基础滚动条 < 坚固> HTML 的脚本。

问题回答

我看到了一个自定义滚动条,但没有滚动功能。 您是否同意使用默认的浏览器滚动条?

如果您删除您的滚动条 divs 并替换您的 overflow:hidden 属性, 并替换 overflow:scroll 。 viewport 属性, 框将使用默认滚动条滚动 。

此处有 < a href=" "http://jsfidle.net/NVTzx/10/" rel= "nofollow" >jsfidle demo.

您可以用 cs 来回滚动条的样式, 见< a href="http://css- tricks.com/custom-scrollbars- in-webkit/" rel=“ no follow” > this article from cs tricks.

希望有帮助!





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!