草庐IT

value_variable

全部标签

javascript - Cloud9 中的 Mocha 测试出现 "undeclared variable"警告

我是node.js和用于单元测试的框架Mocha的新手,但我在cloud9IDE中创建了几个测试只是为了看看它是如何工作的。代码如下所示:varassert=require("assert");require("should");describe('Array',function(){describe('#indexOf()',function(){it('shouldreturn-1whenthevalueisnotpresent',function(){assert.equal(-1,[1,2,3].indexOf(5));assert.equal(-1,[1,2,3].index

javascript - 如何更改h :outputText value by JavaScript?

我已经用2个inputText测试过,它运行良好例如vartdate=document.getElementById('txtDate');//h:inputTextvartdt=document.getElementById('txtDateTime');//h:inputTexttdate.onchange=function(){tdt.value=tdate.value;};如何更改“tdt”-h:outputText的值?vartdate=document.getElementById('txtDate');//h:inputTextvartdt=document.getEle

javascript - chrome.tabs.executeScript : How to get access to variable from content script in background script?

如何从后台脚本background.js中的内容脚本app.js访问变量app?以下是我的尝试方式(background.js):chrome.tabs.executeScript(null,{file:"app.js"},function(){app.getSettings('authorizeInProgress');//...});这是我得到的:这是manifest.json:{"name":"ctrl-vk","version":"0.1.3","manifest_version":2,"description":"Chromeextensionforctrl+vinserti

c# - SCRIPT5009 : 'JSON' is undefined in IE 10 The value of the property '$' is null or undefined, 不是函数对象

HelloWorld$(document).ready(function(){});$(document).ready(function(){$("#width").val($(window).width());$("#height").val($(window).height());});上面是我的aspx代码和jquery脚本,它给出了窗口的高度和宽度。当我从visualstudiohttp://localhost/Mypage.aspx运行web应用程序时,这段代码在所有浏览器上都完美无缺但是当我在iis上托管它并使用我的机器名称http://MyMachine/Mypage.a

javascript - 优化 : Get specific Value(and not more) from IndexedDB

我正在做的是在客户端上保存和检索大量图像。(现在indexedDB对于这个简单的工作来说似乎有点过分了,但是因为它是唯一没有限制的跨浏览器解决方案(比如localStorage),所以我不得不使用它......而且它有效)这是我的数据库的样子:(更具体地说,我的数据库的唯一对象库)#|key(timeID)|value0|812378123|{data:¨....¨,tnData:¨...¨,timeID:812378123}1|912378123|{data:¨....¨,tnData:¨...¨,timeID:912378123}2....KeyValue是一个唯一的TimeID,

javascript - Chrome 扩展 : Storing variables for a tab even if page changes

我正在构建一个Chrome扩展程序。我想知道即使页面发生变化,是否有一种方法可以记住选项卡的js变量。例如。如果我在example1.com上并在同一个选项卡上转到example2.com,我应该保留在example1.com上设置的变量。我不想使用Chrome存储空间。我不能使用localStorage或sessionStorage,因为chrome对不同的域有不同的存储。这可以通过哪些方式实现? 最佳答案 除了使用localStorage(通过后台页面)之外,您还可以通过从内容脚本向后台页面发送消息,将这些变量直接保存在后台页面

javascript - rails : accessing an instance variable in a js. erb 文件

我正在尝试从js.erb文件访问实例变量。#controllerdefget_person@person=Person.find(1)respond_todo|format|format.js{}endend#get_person.js.erbalert('')当我浏览到[controller_name_here]/get_person.js时...我在@person上收到一个nil对象错误。(我知道Person.find(1)返回一个对象)注意:我实际上在渲染js.erb文件中的部分内容时遇到了问题,我正在尝试找出原因。 最佳答案

javascript - knockout : Change css class based on value of observable

我在可观察数组上使用foreach:如您所见,我将可用性的当前值传递给函数availabilityCssClass,该函数将该值与一些预定义的字符串进行比较。根据匹配的字符串,它返回一个类名。self.availabilityCssClass=ko.computed(function(value){varavailability=value;if(availability==="Busy"||"DoNotDisturb"||"BeRightBack")return"leftStatusCellColorOrange";elseif(availability==="Away"||"Off

javascript - 以现代方式获取 <select> 的值(value)?

我是undertheimpression为了从中获取值你基本上必须这样做:varsel=document.getElementById("my-select");varval=sel.options[sel.selectedIndex].value;但是我ranintosomecodetoday这就是document.getElementById('my-select').value,这似乎在Chrome和Firefox中运行良好。最近有变化吗,还是一直这样?这支持多远? 最佳答案 mySelect.value至少从1998年10月

javascript - Node : Passing function specific variables to Async. 并行()

在Node中呈现页面之前,我需要完成大量长时间运行的数据库查询。这些查询中的每一个都需要一些自己的变量。有没有一种简单的方法可以将变量传递给nodejs中的async.parallel()实用程序?async.parallel([queryX(callback,A1,A2,A3),queryX(callback,B1,B2,B3),queryY(callback,C1,C2,C3),queryY(callback,D1,D2,D3),queryZ(callback,E1,E2,E3),queryZ(callback,F1,F2,F3),],function(err,results){/