clearinterval

Need to clearInterval in iframe from parent and it's not working

佐手、 提交于 2021-01-29 02:05:05
问题 I'm using setInterval inside an iframe, and I need to be able to stop it from the parent window, and it doesn't seem to be working. I'm assigning a global variable ('modelViewRefresh') to the setInterval event to be accessed from the parent. I'm using this code in the parent to try and trigger clearInterval, but it doesn't seem to be working: var modelViewRefresh = document.getElementById(widget_id + '_iframe').contentWindow['modelViewRefresh']; console.log("modelViewRefresh=" +

How to use clearInterval() in Angular 4

落花浮王杯 提交于 2020-06-24 08:38:29
问题 I am trying to use setInterval in my Angular 4 app. const inter = setInterval(() => { // logic resulting in exitCondition if(exitCondition) { clearInterval(inter); } }, 1000); This set up works fine in vanilla javascript, but clearInterval() does not seem to work in Angular. Upon doing some research I found an interval service for Angular 1.x : https://docs.angularjs.org/api/ng/service/$interval Is there anything similar for Angular 4? Or is there a workaround to make clearInterval() work?

clearInterval doesn't clearInterval

扶醉桌前 提交于 2020-04-30 16:32:15
问题 var timer; function check_element_load(){ timer = window.setInterval(function(){ console.log("still working"); // keeps running forever if(document.getElementById("comments")){ console.log("FOUND"); // this actually runs document.getElementsByTagName("fb:comments")[0].setAttribute('order_by', 'social'); window.clearInterval(timer); // < not effective } }, 50); } check_element_load(); I'm trying to put a script on top to keep checking if a specific element was successfully loaded in the

Vue——长按元素实现某种操作

点点圈 提交于 2020-03-22 12:48:59
  首先描述一下需求,就是希望在长按元素的时候实现某种操作,话不多说,下面就介绍一下方法: 给需要长按的元素添加 touchstart 和 touchend 两个事件: <div v-for="(item, index) in fileList" :key="index" @touchstart="touchstart(index,item)" @touchend="touchend(index)"> // 这里是循环的一些元素 </div> 在methods中添加事件: touchstart(index,item) { clearInterval(this.Loop); //再次清空定时器,防止重复注册定时器 this.Loop = setTimeout(function() { //这里是长按以后需要触发的事件 }.bind(this), 1000); // 这里的1000是指需要长按的时间,单位为ms }, touchend(index) { // 这个方法主要是用来将每次手指移出之后将计时器清零 clearInterval(this.Loop); }   通过上面的两步就能实现长按事件了。 来源: https://www.cnblogs.com/belongs-to-qinghua/p/12545384.html

javascript学习-原生javascript的小特效(简单的运动效果)

本秂侑毒 提交于 2020-03-05 06:54:27
前些日子看了个视频所以就模仿它的技术来为大家做出几个简单的JS小特效 一:运动特效(主要是通过改变元素的left,right,height,width,opacity来达到运动的效果) 我们今天做一个利用计时器来创建一个匀速运动的效果,代码很简单。 1:首先我们先写出HTML的结构 <div id="div1"> <span id="share">share</span> </div> 2:给出样式 <style type="text/css"> body{margin: 0;padding: 0;} span{background: blue;width: 50px;height: 60px;position: absolute;right:-48px;color: #fff;top: 47px;} div{background: red;width: 200px;height: 150px;position: relative;left: -200px;} </style> 3:然后到了我们的JS部分 <script type="text/javascript"> window.onload=function(){ 页面内容完全载入的时候执行这个匿名函数 var div=document.getElementById("div1"); 获取div div.onmouseover

How can I depend on the interval that I just cleared in jquery?

混江龙づ霸主 提交于 2020-01-25 03:55:32
问题 It's a follow up to this question - https://stackoverflow.com/a/33430608/3766930 Basically I have a text area and when user starts typing in sth, the counter starts going down from 3 to 0. when it reaches 0 it gets disabled. Now I want to add a feature of starting over - when user clicks the link start over , text area goes enabled again and user has 3 seconds (again) to perform the input. I modified the jquery script: $('#textArea').on('input propertychange', display30Seconds); var interval;

Display Loading Animation Spinner while Loading Page

跟風遠走 提交于 2019-12-30 13:30:35
问题 I want to show loading animation spinner in a JQueryMobile page which is loaded w/ ajax off. The page is loaded with data-ajax="false" or rel="external" I tried on pagebeforecreate and pageshow event but its NOT working as I expected: $( '#page' ).live( 'pagebeforecreate',function(event){ $.mobile.loading('show'); }); $( '#page' ).live( 'pageshow',function(event){ $.mobile.loading('hide'); }); 回答1: There's a slight problem with your request. First, you will not be able to show/hide ajax