Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript滚动到顶部脚本amendment_Javascript_Html_Css_Scrolltop - Fatal编程技术网

Javascript滚动到顶部脚本amendment

Javascript滚动到顶部脚本amendment,javascript,html,css,scrolltop,Javascript,Html,Css,Scrolltop,我正在尝试修改这个脚本,以便在topcontrol div元素不可见(不透明度为0)时,它不可单击,因为即使topcontrol div的不透明度为0,它仍然可以单击(并且仍然可以调用移动到顶部的函数)-如果您将鼠标悬停在div所在的位置,它也会显示标题(我本来打算去掉标题,所以只需要确保点击它什么也不做)。此外,我似乎无法更改css游标属性,在设置visibility属性时,我尝试将其与不透明度值一起更改,但它似乎不起作用,它只是保持最初设置的状态 任何建议/帮助都将不胜感激,因为我的java

我正在尝试修改这个脚本,以便在topcontrol div元素不可见(不透明度为0)时,它不可单击,因为即使topcontrol div的不透明度为0,它仍然可以单击(并且仍然可以调用移动到顶部的函数)-如果您将鼠标悬停在div所在的位置,它也会显示标题(我本来打算去掉标题,所以只需要确保点击它什么也不做)。此外,我似乎无法更改css游标属性,在设置visibility属性时,我尝试将其与不透明度值一起更改,但它似乎不起作用,它只是保持最初设置的状态

任何建议/帮助都将不胜感激,因为我的javascript知识非常丰富

//** jQuery Scroll to Top Control script- (c) Dynamic Drive DHTML code library:     http://www.dynamicdrive.com.
//** Available/ usage terms at http://www.dynamicdrive.com (March 30th, 09')
//** v1.1 (April 7th, 09'):
//** 1) Adds ability to scroll to an absolute position (from top of page) or specific element on the page instead.
//** 2) Fixes scroll animation not working in Opera. 


var scrolltotop={
//startline: Integer. Number of pixels from top of doc scrollbar is scrolled before showing control
//scrollto: Keyword (Integer, or "Scroll_to_Element_ID"). How far to scroll document up when control is clicked on (0=top).
setting: {startline:500, scrollto: 0, scrollduration:600, fadeduration:[600, 400]},
controlHTML: '<div class="scroll-button"></div>', //HTML for control, which is auto wrapped in DIV w/ ID="topcontrol"
controlattrs: {offsetx:20, offsety:100}, //offset of control relative to right/ top of window corner
anchorkeyword: '#top', //Enter href value of HTML anchors on the page that should also act as "Scroll Up" links

state: {isvisible:false, shouldvisible:false},

scrollup:function(){
    if (!this.cssfixedsupport) //if control is positioned using JavaScript
        this.$control.css({cursor:'default', opacity:0}) //hide control immediately after clicking it
    var dest=isNaN(this.setting.scrollto)? this.setting.scrollto : parseInt(this.setting.scrollto)
    if (typeof dest=="string" && jQuery('#'+dest).length==1) //check element set by string exists
        dest=jQuery('#'+dest).offset().top
    else
        dest=0
    this.$body.animate({scrollTop: dest}, this.setting.scrollduration);
},

keepfixed:function(){
    var $window=jQuery(window)
    var controlx=$window.scrollLeft() + $window.width() - this.$control.width()  - this.controlattrs.offsetx
    var controly=$window.scrollTop() + $window.height() -  this.$control.height() - this.controlattrs.offsety
    this.$control.css({left:controlx+'px', top:controly+'px'})
},

togglecontrol:function(){
    var scrolltop=jQuery(window).scrollTop()
    if (!this.cssfixedsupport)
        this.keepfixed()
    this.state.shouldvisible=(scrolltop>=this.setting.startline)? true : false
    if (this.state.shouldvisible && !this.state.isvisible){
        this.$control.stop().animate({cursor:'pointer', opacity:1}, this.setting.fadeduration[0])
        this.state.isvisible=true
    }
    else if (this.state.shouldvisible==false && this.state.isvisible){
        this.$control.stop().animate({cursor:'default', opacity:0}, this.setting.fadeduration[1])
        this.state.isvisible=false
    }
},

init:function(){
    jQuery(document).ready(function($){
        var mainobj=scrolltotop
        var iebrws=document.all
        mainobj.cssfixedsupport=!iebrws || iebrws && document.compatMode=="CSS1Compat" && window.XMLHttpRequest //not IE or IE7+ browsers in standards mode
        mainobj.$body=(window.opera)? (document.compatMode=="CSS1Compat"? $('html') : $('body')) : $('html,body')
        mainobj.$control=$('<div   id="topcontrol">'+mainobj.controlHTML+'</div>')
            .css({position:mainobj.cssfixedsupport? 'fixed' : 'absolute', top:mainobj.controlattrs.offsety, right:mainobj.controlattrs.offsetx, opacity:0, cursor:'default'})
            .attr({title:'Scroll Up'})
            .click(function(){mainobj.scrollup(); return false})
            .appendTo('body')
        if (document.all && !window.XMLHttpRequest && mainobj.$control.text()!='') //loose check for IE6 and below, plus whether control contains any text
            mainobj.$control.css({width:mainobj.$control.width()})    //IE6- seems to require an explicit width on a DIV containing text
        mainobj.togglecontrol()
        $('a[href="' + mainobj.anchorkeyword +'"]').click(function(){
            mainobj.scrollup()
            return false
        })
        $(window).bind('scroll resize', function(e){
            mainobj.togglecontrol()
        })
    })
}

我看了一下你的页面,但说实话,我不知道你在说什么div,也不知道我看到了什么行为会促使我知道你在说什么div:-)。我在“猜测”你指的是导航。你能说得更具体一点吗。即。。“当我滚动并显示div时,我不想点击它”等等。你在哪个浏览器上测试?在IEs设置中
不透明度:0
使鼠标事件保持活动状态。相反,您可以使用
背景+颜色:透明
,尽管这不会阻止其他浏览器中的mouseevents,在这些浏览器中(&IE11)您可以使用
指针事件:无
,创建无响应元素。为什么不直接使用
显示:无
?通过操作
.fadeIn()
.fadeOut()
?目前我正在chrome和firefox中测试它,打算转向ie,不过我会尝试使用.fadeIn()和.fadeOut()修复所有问题。
scrolltotop.init()