草庐IT

link-to-function

全部标签

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

javascript - JavaScript 中 Number 和 Function.prototype 之间的关系是什么?

我正在阅读Javascript:theGoodParts这本书。当我阅读下面的代码时,我有点困惑:Function.prototype.method=function(name,func){this.prototype[name]=func;returnthis;};Number.method('integer',function(){returnMath[this我认为上面代码的第一部分意味着JavaScript中的任何函数现在都有一个名为method的方法。但是“数字”也是一个函数吗?为什么Number.method有意义?我假设Number继承了Number.prototype,

javascript - 谷歌地图 v3 : Any way to force a high maximum Zoom Level (maxZoom 24)?

我们正在开展一个考古测绘项目,我们在该项目中对数百张手绘map进行了地理配准。这些都可以在非常高的缩放级别下查看,这在Googlemap中转换为缩放级别22、23和24。但是,默认情况下,google-maps类型Map只能达到zoom级别21。我尝试了几种方法来强制将最大缩放级别提高到24,但这里建议的几种方法已被证明是笨拙且不一致的(例如,强制用户切换到卫星然后返回map以获取它可以工作)。有人知道如何有效地执行24的maxZoom吗? 最佳答案 GoogleMapsAPI有一个名为numZoomLevels的属性。您需要使用适

javascript - rails 4,当需要 jquery,jquery_ujs 时,link_to 无法使用销毁操作

为什么在application.js文件中需要jquery后销毁操作不兼容?如何在不忽略jquery的情况下使销毁操作再次起作用?帖子索引View:h1Blog-@posts.eachdo|post|h2=link_topost.title,postp=post.contentp=link_to'Edit',edit_post_path(post)p=link_to'Delete',post,data:{confirm:"Areyousure?"},method::deletebrp=link_to'Addanewpost',new_post_path销毁帖子Controller中的A

javascript - react 代码抛出 “TypeError: this.props.data.map is not a function”

我刚开始用React编码,我习惯用CoffeeScript编码。我试着沿着tutorialpresentedintheReactdocs编码并为状态更新做了类似的事情。但是,我收到TypeError:this.props.data.mapisnotafunction。我有点迷茫,想知道我哪里错了。有人可以指导我并告诉我哪里出错了吗?这是我的代码:(function(){varStatus,StatusBox,StatusForm,StatusList,button,div,h4,textarea,_ref;_ref=React.DOM,div=_ref.div,textarea=_re

javascript - 如何使 "undefined is not a function"错误更有用?

考虑这段JavaScript代码:varx=newdate()//"ReferenceError:dateisnotdefined"-usefulerror,hintsatatypo('D'ate)varx=newMyClass.foo()//"TypeError:undefinedisnotafunction"-baderror,nohintitmightbe'F'oo错误本身是正确的,因为MyClass没有foo方法,所以MyClass.foo确实返回了undefined,new不喜欢这样。问题是这根本没有暗示用户可能拼错了方法名称。现实生活中的例子:newMeteor.colle

javascript - 火狐插件 : How to override native js function

我正在尝试使用pageMod在页面加载时运行脚本:但我看不到它的效果vardata=require("sdk/self").data;varattachTo=require("sdk/content/mod").attachTo;varpageMod=require("sdk/page-mod");pageMod.PageMod({include:"*",contentScriptWhen:"start",allow:true,attachTo:["existing","top"],contentScriptFile:[data.url("jquery-2.1.1.min.js"),d

javascript - 如何转换 10 :09:00 GMT+0000 to IST in javascript?

我正在开发网络应用程序,因为我们正在使用CK编辑器日历。我在其中执行以下代码以获取Date&Time..代码:varstrDate=newDate(event.start);varendDate=newDate(event.end);vartitle='Event:'+event.title+'From:'+event.start.toLocaleString()+'To:'+event.end.toLocaleString()+'By:';输出:FriFeb13201510:37:00GMT+0000To:FriFeb13201510:37:00GMT+0000预期输出:在上面的输出

javascript - 期望失败 : "Expected [ ] to be empty array."

这是失败的测试:describe("Checkingerrors",function(){varscope={};beforeEach(function(){browser.get("/#endpoint");browser.waitForAngular();scope.page=newMyPage();});it("shouldnotshowanyerrors",function(){expect(scope.page.errors).toBeEmptyArray();});});其中MyPage是一个页面对象:varMyPage=function(){this.errors=ele

javascript - 检测 Node.js 中的硬链接(hard link)

如何判断文件系统路径是否是Node.js的硬链接(hardlink)?函数fs.lstat给出了一个stats对象,当给定硬链接(hardlink)时,该对象将为stats.isDirectory()和返回truestats.isFile()分别。fs.lstat没有提供任何东西来说明普通file或directory与链接文件之间的区别。如果我对链接(ln)工作原理的理解是正确的,那么链接文件指向磁盘上与原始文件相同的位置。这意味着原始文件和链接版本是相同的,并且无法区分原始文件和链接文件。我正在寻找的功能如下:Thisishypotheticalpseudo-codefordemon