草庐IT

of_device_get_match_data

全部标签

javascript - 如何使用javascript获取没有$_GET参数的url路径?

如果我当前的页面是这种格式...http://www.mydomain.com/folder/mypage.php?param=value有没有简单的方法可以得到这个http://www.mydomain.com/folder/mypage.php使用javascript? 最佳答案 不要执行此正则表达式和拆分内容。使用浏览器的内置URL解析器。window.location.origin+window.location.pathname如果您需要解析不是当前页面的URL:varurl=document.createElement(

javascript - 未捕获的类型错误 : Cannot call method 'replace' of undefined underscore. js

我是backbone.js和underscore.js的新手。HTML:我调用View文件的地方:JS函数(与javascript项目配合良好):functionCart(){......this.showCart=function(){varitem=deserializeJSONToObj(window.localStorage.getItem(Cart.storageName));varstr='';str+='ItemtobuyQuantity';$.each(item,function(i,item){str+=''+trimString(item.Name,50)+'Ava

javascript - 使用 angular-mocks 匹配所有 GET url for backendless

我现在正在编写一个没有后端ajax的前端。我正在使用angular-mocks来模拟这样的API调用:$httpBackend.when('GET','/somelink').respond(function(method,url,data){//dosomething});但是,如果ajax传递params:{id:12345},它将附加到url为'/somelink?id=12345'。catchwhen('GET','/somelink')有没有办法使用RegEx或一些技巧来解决这个问题?只是为了不管params里面有什么,respond()仍然会被调用?谢谢。更新1:我不能使用

javascript - 全日历 v2 错误 : Uncaught TypeError: Cannot read property 'month' of undefined

我在添加事件时使用了选择回调。以下代码在v1中有效,但我在v2中遇到了UncaughtTypeError。当我删除ajax代码时没有错误,但我当然需要将新事件添加到数据库中。select:function(start,end,jsEvent,view){vartitle='Available';vareventData;eventData={title:title,start:start};$.ajax({type:'POST',url:'add-event.php',data:eventData,success:function(data){$('#calendar').fullCa

javascript - 未捕获的类型错误 : Cannot set property offsetWidth of#<HTMLElement> which has only a getter

我正在使用AngularJS开发网络应用程序。我有一个不知从何而来的错误,它工作正常,但我真的不知道为什么它不再工作了。所以它在指令中,我尝试设置属性offsetWidth指令html模板中的一个元素。因为我真的不知道它可能来自哪里,所以我会给你我的指令和模板的完整代码。该指令创建一个应用程序按钮并处理其点击时的视觉效果。这是行$element[0].offsetWidth=$element[0].offsetWidth;这会触发错误。(这是重启动画的技巧)我再说一遍,这段代码工作正常而且我几乎可以肯定我没有做任何更改。我正在使用Chrome进行调试,也许它来自于它?错误:Uncaug

javascript - flowtype 绑定(bind)导致错误 `Convariant property incompatible with contravariant use in assignment of property`

这个表达式对于javascript/react来说非常简单,将函数绑定(bind)到this范围。this.toggle=this.toggle.bind(this);但是当引入flowtype时,会导致错误:我该怎么做才能通过流量测试?toggle可以是任何函数,甚至可以是空函数。toggle(){///donothing} 最佳答案 你必须在你的类中将你的toggle声明为Function(紧凑的方式):classFoo{toggle:Function=(){...}}或者,您可以将签名和实际方法分开:classFoo{togg

javascript - Chrome 扩展 : How to get user name?

我正在创建一个谷歌浏览器扩展程序。对于某些功能,我需要用户的系统登录名(无密码)。通过使用JavaScript,这是不可能的。有人建议NPAPI,但我对此一无所知,所以我放弃了。接下来我将尝试在Chrome浏览器中获取用户名。但仍然没有成功。我尝试使用类似的东西:varcurrentUser;varxhr=newXMLHttpRequest();xhr.onreadystatechange=function(data){if(xhr.readyState==1){currentUser=null;if(xhr.status==200){varre=newRegExp(/[\s]*([^

javascript - Sequelize : Find All That Match Contains (Case Insensitive)

我想使用sequelize.js查询模型以获取包含约束的记录。我该怎么做?这是我现在拥有的:Assets.findAll({limit:10,where:["asset_namelike?",'%'+request.body.query+'%']}).then(function(assets){returnresponse.json({msg:'searchresults',assets:assets});}).catch(function(error){console.log(error);});但我收到以下错误:{error:operatordoesnotexist:charact

javascript - jQuery.ajax() 在 Chrome 扩展中将 POST 请求作为 GET 发送

我正在构建一个小型Chrome扩展程序,它必须通过POSThttp请求将消息发送到我公司网络中的服务器,并且我正在使用jQuery1.4.1来加速javascript部分的开发。我有这个代码来发送请求:functionsend(){$.ajax({url:"http://mycompany.com/update",method:"POST",data:{status:"sometest",in_reply_to_status_id:"anId"},success:function(data,textStatus){console.log("success");console.log(d

javascript - ParsleyJS - 使用 data-parsley -`constraint` -message 进行本地化

目前我正在使用data-parsley-`constraint`-message="Englishsentencegoeshere"但现在我正在努力添加本地化,​​这些消息将永远不会使用i18n库进行翻译,因为它们是自定义的。有没有办法添加类似的东西data-parsley-`constraint`-message-fr="Francaisfrancaisfrancais"或者通过JS来实现?具体来说,我正在使用data-parsley-required-message="" 最佳答案 为什么不使用Parsley的本地化而不是在输入