草庐IT

events_top

全部标签

javascript - jQuery .css ("margin-top",值)在 IE 8(标准模式)中不更新

我正在构建一个绑定(bind)到$(window).scroll()事件的自动跟随div。这是我的JavaScript。varalert_top=0;varalert_margin_top=0;$(function(){alert_top=$("#ActionBox").offset().top;alert_margin_top=parseInt($("#ActionBox").css("margin-top"));$(window).scroll(function(){varscroll_top=$(window).scrollTop();if(scroll_top>alert_to

javascript - IE Bug (window === top) === false

在IE中。window===top;//falsewindow===window.window//falsewindow==top;//truewindow==window.window//true在FF3.6和Chrome稳定版中不会发生这种情况。在IE中,typeof、.toString、Object.prototype.toString.call都返回相同的top&窗口这与this有关.谁能告诉我为什么IE不能做严格等效?请注意,循环引用不会在IE和Chrome中引起问题。o={};o.o=o;o===o.o;//true结果window.window===window.top;

javascript - jQuery/JavaScript : Click event on a checkbox and the 'checked' attribute

代码:$('input.media-checkbox').live('click',function(e){e.preventDefault();varthat=$(this);if(that.attr('checked')=='checked'){varm=that.attr('media');varmid='verify_'+m;that.parents('div.state-container').find('ul.'+mid).remove();that.attr('checked',false);}else{varurl=AJAX_URL;$.ajax({type:'GET'

javascript - jQuery position().top 返回 0 而不是实际值

根据jQuery官方文档,这个函数应该:“获取匹配元素集中第一个元素的当前坐标,相对于偏移父元素。”以下代码应返回值51,但它返回值0。任何人都可以提供见解以及原因吗?提前致谢。我知道添加css(top:xx)是有效的,如果是这样,这是否意味着position()仅适用于元素具有top的css属性的情况?.outer{width:200px;height:200px;overflow-y:auto;border:1pxdottedgrey;position:absolute;}.inner{width:50px;height:50px;margin-top:50px;border:1p

javascript - react .js : the most efficient way to pass a parameter to an event handler without bind() in a component

当事件处理程序使用this时(像下面的handleClick一样使用this.setState),你必须将事件处理程序与this关键词。否则,您需要使用thearrowfunction.例如//Thisfunctionisn'tboundwhilstusing"this"keywordinsideofit.//Still,itworksbecauseitusesanarrowfunctionhandleClick=()=>{this.setState({isClicked:true});}render(){return(Click);}但是,使用上述方法,您不能传递参数。您需要使用..

javascript - 谷歌地图 API v3 : Is there a callback or event listener for a setMap() event?

我正在开发的网站上使用GoogleMapsAPIv3。我的map下方有一个下拉框,允许用户在map上显示的不同标记集之间切换。每个标记都使用marker.setMap()显示。我的问题是map有时需要很长时间才能显示新标记,尤其是在IE中。我想在map切换标记时显示“正在加载”动画。但我不知道如何检测map何时完成显示新数据(没有页面加载,因为这都是AJAX)。setMap()事件是否有回调或事件监听器,以便我可以在最后一个标记完成加载时调用一个函数来停止“正在加载”动画? 最佳答案 setMap()似乎没有回调或事件监听器,但我想

javascript - 谷歌分析异步 : Events Tracking Callback?

我希望使用事件跟踪来记录对指向另一个网站的特定类型链接的点击。我正在使用jQuery,我目前拥有的代码是:$('a.website').click(function(event){varhref=$(this).attr('href');try{_gaq.push(['_trackEvent','website','click',href]);}catch(err){}});但是,在看到其他站点的referrer信息后,我不相信这是准确跟踪点击,可能是因为_gaq.push是异步的,并且在浏览器导航到url,并终止当前页面上运行的任何javascript。有什么方法可以检测到_gaq.

javascript - Chrome 扩展 : have an extension listen for an event on a page?

我有一个为我的网站制作的chrome扩展程序,目前我有一个扩展程序每分钟检查一次数据库以获取更新。是否可以让扩展程序监听实际页面上的事件?像这样this.trigger('sendUpdate',data)//thishappenedonthepagethis.on(sendUpdate,function(){//thisiswhatthechromeextensionlistensfor//dostuffwithdata}) 最佳答案 您需要添加一个content_script。content_script具有对DOM的完全访问权

javascript - 在JavaScript事件处理中,为什么 "return false"或 "event.preventDefault()"和 "stopping the event flow"会有区别?

据说当我们处理一个“点击事件”时,返回false或者调用event.preventDefault()是有区别的,其中thedifferenceisthatpreventDefaultwillonlypreventthedefaulteventactiontooccur,i.e.apageredirectonalinkclick,aformsubmission,etc.andreturnfalsewillalsostoptheeventflow.那是不是说,如果click事件被多次注册了好几个action,用$('#clickme').click(function(){…})返回fals

javascript - getBoundingClientRect().top 和 offsetTop 之间的区别?

getBoundingClientRect().top和offsetTop有什么区别?https://codepen.io/anon/pen/bWZWQgconstelem=document.querySelector('#find');console.log('getBoundingClientRect:'+elem.getBoundingClientRect().top);console.log('offsetTop:'+elem.offsetTop);//StufftopushthedivdownthepageFindme从我的快速测试来看,唯一的区别似乎是返回的小数位数。