为什么这个Else条件被执行?(Why this Else condition is executed?)
我试图理解这个Zabiullah剧本,我在“ https://www.experts-exchange.com/questions/24623403/Can-a-Sharepoint-page-be-refreshed-automatically-but-just- once.html “。 他的职位是从2009年开始的,从那时起他一直没有活跃,所以我在这里问。
这段代码应该在beginn时只重新载入页面一次,并防止下次重新载入页面。 代码工作完美,但我不明白if(arguments.length == 1)的Else条件是否被执行,因为funktion总是被setReloadTime(5)调用,这意味着它会是真的吗?
var reloadTimer = null; var sURL = window.location.href; function setReloadTime(secs) { if (arguments.length == 1) { if (reloadTimer) clearTimeout(reloadTimer); reloadTimer = setTimeout("setReloadTime()", Math.ceil(parseFloat(secs) * 1000)); } else { if (sURL.indexOf("loaded=1") == -1) { reloadTimer = null; var queryString = location.search.substring(1); sURL += (queryString ? "&" : "?") + 'loaded=1'; window.location = sURL; } else { clearTimeout(reloadTimer); } } } setReloadTime(5);
i'm trying to understand this script of Zabiullah, which i found in "https://www.experts-exchange.com/questions/24623403/Can-a-Sharepoint-page-be-refreshed-automatically-but-just-once.html". His post was from 2009 and he hasn't been active since then, so im asking here.
This code should reload the page only once at the beginn and prevent it from reloading next time. The code worked perfectly, but i can't understand when the Else condition of if(arguments.length ==1) is executed, since the funktion is allways called by setReloadTime(5), meaning it would be allways true ?
var reloadTimer = null; var sURL = window.location.href; function setReloadTime(secs) { if (arguments.length == 1) { if (reloadTimer) clearTimeout(reloadTimer); reloadTimer = setTimeout("setReloadTime()", Math.ceil(parseFloat(secs) * 1000)); } else { if (sURL.indexOf("loaded=1") == -1) { reloadTimer = null; var queryString = location.search.substring(1); sURL += (queryString ? "&" : "?") + 'loaded=1'; window.location = sURL; } else { clearTimeout(reloadTimer); } } } setReloadTime(5);
原文:https://stackoverflow.com/questions/50472066
最满意答案
您有一个上下文:
.getContext('2d')
为画布返回CanvasRenderingContext2D
。 它不会创建新的上下文。 所以,当你cx2.clearRect(0,0,300,300);
你也清除了cx1
因为,它是相同的上下文。如果你想要单独的“图层”,你需要创建单独的
<canvas>
并将它们放在彼此的顶部。You have one context:
.getContext('2d')
returns theCanvasRenderingContext2D
for the canvas. It does not create new contexts. So, when youcx2.clearRect(0,0,300,300);
you're also clearingcx1
because, well, it's the same context.If you want separate "layers" you need to create separate
<canvas>
's and position them on top of each other.
相关问答
更多-
如果您需要在代码中设置颜色(使用ColorStateList),但仍然希望将颜色状态保留在XML中,则可能需要使用以下命令: try { XmlResourceParser parser = getResources().getXml(R.color.your_colors); ColorStateList colors = ColorStateList.createFromXml(getResources(), parser); mText.setTextColor(colors) ...
-
我就是这样做的: static private Random randomGen = new Random(); public static Color GetRandomizedKnownColor() { int number; do { number = randomGen.Next(28, 168); } while (number == (int)KnownColor.White); return Color.FromKnownColor( ...
-
OpenGL颜色高于1(OpenGL colors above 1)[2022-11-29]
听起来像是一个驱动程序错误(没有输入值的剪辑),并且由于开发人员采用的快捷方式,它会影响其他通道。 看起来像这样的代码 uint32_t packed_bgra = ((b*0xff) << 24) | ((g*0xff) << 16) | ((r*0xff) << 8) | (a*0xff); 我要提交错误报告。 Sounds to me like a driver bug (no clip of the input value) and that it affects the other channe ... -
假设我完全明白你在问什么,你就非常接近在那里。 我认为你的代码中的问题是如何拆分系列公式以获得标签颜色。 我打开了这个图表,列标题是这样的: 使用以下代码进入下面的图表: Sub SetColors() Dim oChart As ChartObject Dim MySeries As Series For Each oChart In ActiveSheet.ChartObjects For Each MySeries In oChart.Chart.SeriesCollection ...
-
奇怪的白色盒子控制(Strange white box covering controls)[2022-12-31]
您的按钮边距=“454,15,10,378”限制了按钮的可用空间。 如果你让窗口变大,你会看到整个按钮。 编辑 有不同的方式来组织XAML中的布局,但通常网格是一个不错的选择。 这是您可以编写它的一种方式。... -
您有一个上下文: .getContext('2d')为画布返回CanvasRenderingContext2D 。 它不会创建新的上下文。 所以,当你cx2.clearRect(0,0,300,300); 你也清除了cx1因为,它是相同的上下文。 如果你想要单独的“图层”,你需要创建单独的
-
起初..不要使用UINavigationBar.appearance()。barTintColor = UIColor.blackColor() 如果你有一个带有UINavigationController的故事板,那么将色调颜色设置为你的UINavigationBar。 每个UINavigationController只有一个navigationBar 对于所有情况,您都无法使用丑陋的外观工具处理您的颜色。 一些控制器(MailComposer,PhotoRoll,...)使用黑色BarButton,有些 ...
-
设置反汇编视图颜色(Set disassembly view colors)[2022-07-05]
我还在Eclipse CDT论坛上问过这个问题,并由Marc Khouzam通知: “反汇编”视图和“内存浏览器”尚未调整为自动更改“黑暗”主题的颜色。 您可以通过转到Preferences-> Traditional Memory Rendering来更改内存浏览器的颜色。 我认为没有办法改变反汇编视图的颜色。 所以我在eclipse cdt.debug错误跟踪器中添加了一个错误报告,在这里: https ://bugs.eclipse.org/bugs/show_bug.cgi?id = 501609, ... -
而不是存储返回的名称,只需存储返回的颜色对象。 然后你可以直接分配它而不是去往字符串值。 编辑:如果您不能将其存储为颜色对象,则使用ToArgb的整数值。 然后,您可以使用FromArgb方法加载它。 Color c = Color.Red; int redColor = c.ToArgb(); //... this.BackColor = Color.FromArgb(redColor); Instead of storing the name that came back, just store ...
-
就盒子而言,你可以为它创建一个div(我看到你已经完成了: .container )。 要圆角,你需要使用CSS属性border-radius : HTML:Hello!CSS: #example1 { width: 100px; background: green; border-radius: 15px; margin: 0 auto; text-align: center; } JSFiddle示例 A ...