草庐IT

one_cookie

全部标签

Javascript 测试 : Selenium cookies data url

只要需要Javascript,我就有一个运行Selenium的Behat测试。如果使用Javascript(因此Selenium被禁用),我当前的Behat测试工作正常。目前,我从Selenium得到的唯一错误反馈是以下语句:unknown:Failedtosetthe'cookie'propertyon'Document':Cookiesaredisabledinside'data:'URLs.(Sessioninfo:chrome=48.0.2564.109)(Driverinfo:chromedriver=2.20.353124(035346203162d32c80f1dce58

javascript Chrome 扩展无法读取 httponly cookie

我需要删除在我的chrome浏览器中设置的gmailcookies,使用chrome扩展程序,但它可以删除除Gmailcookies之外的所有cookies,然后我注意到Gmailcookies是httponly,有没有办法使用javascriptchrome扩展程序删除它们..谢谢:) 最佳答案 Chrome扩展可以使用chrome.cookiesAPI,它可以访问cookie存储中的所有cookie,包括httpOnly。API的文档是here.请注意,此API需要声明权限并且不能在内容脚本中使用。

javascript es6 导入 "expects exactly one argument"

我正在尝试使用es6模块,但遇到错误:SyntaxError:Unexpectedidentifier'GameObject'.importcallexpectsexactlyoneargument.顺便说一句,这是在macOS10.13上的Safari11中。这是我的模块:exportclassGameObject{//code}exportclassGameLoop{//code}相关html:以及尝试使用该模块的脚本,它在第1行给出了上述错误:importGameObjectfrom"./gameFoundation.js"importGameLoopfrom"./gameFou

javascript - ruby 轨道 : Render HTML partial as a one line of string

有没有办法将html.erb部分呈现为一行字符串?我正在尝试在javascript中呈现_foo.html.erb部分,这样我就可以将整个html文档用作字符串变量。我试过下面的代码:varfoo=""foo"%>";在_foo.html.erb中,假设我有以下内容:HelloWorld这种方式会在javascript中给我一个语法错误,因为部分中有CRLF。但是如果我写这样的代码...Hello"+"World现在,这不是javascript中的错误。我可以采用后一种方式,但如果部分包含大量带有ruby​​脚本的代码行,那将是一场灾难。还有其他方法吗?提前致谢。

javascript - Axios 不会发送 cookie,Ajax (xhrFields) 就可以了

使用AxiosexportfunctionsendAll(){return(dispatch)=>{dispatch(requestData());returnaxios({method:'POST',url:`${C.API_SERVER.BASEURL}/notification/sendAll`,data:{prop:'val'},//responseType:'json',headers:{'Content-Type':'application/json'},withCredentials:true}).then((response)=>{dispatch(receiveDat

javascript - 设置 cookie 在 2 小时后过期

我有这段JavaScript代码:functionspu_createCookie(name,value,days){if(days){vardate=newDate();date.setTime(date.getTime()+(days*24*60*60*1000));varexpires=";expires="+date.toGMTString();}elsevarexpires="";document.cookie=name+"="+value+expires+";path=/";}如何让cookie在2小时后过期? 最佳答案

javascript - 相当于 jQuery one() 的 JS

有人可以指出我以下问题的解决方案吗?我正在尝试为这个jQuery代码找到一个JS等价物:varformSelector='myselectorhere';varattribute='name';varformHistory=[];$(formSelector).one('focusout',function(e){formHistory.push(e['target'].getAttribute(attribute));}); 最佳答案 更新在大多数浏览器中,您现在可以在选项对象中传入once:true:document.getEl

javascript - 有没有办法为 1 个请求设置 cookie?

我想设置一个cookie(使用JavaScript或jQuery)只发送一次。我可以在发出请求之前设置一个cookie的过期日期,比如1秒后,但这似乎有点微妙。我想知道是否有一种方法可以保证cookie在1个请求中存活,并且只有一个请求...我看过thedocsonMDN但看不到任何符合要求的东西。有什么想法吗? 最佳答案 您可以使用AJAX完成处理程序在每次请求后删除cookie。https://api.jquery.com/ajaxComplete/$(document).ajaxComplete(function(){//de

javascript - Next js 和 Apollo - Cookie 未被传递

我将NextJS与Apollo一起使用,并在我的数据HOC中使用以下配置对其进行了设置:import{ApolloClient}from'apollo-client';import{InMemoryCache}from'apollo-cache-inmemory';import{HttpLink}from'apollo-link-http';import{onError}from'apollo-link-error';import{withClientState}from'apollo-link-state';import{getMainDefinition}from'apollo-u

javascript - Node.js CORS session cookie 与 Angular.js

我正在使用带有CORS和Angular.js的Node.js进行简单登录。那是---client.example.com也在进行POSTapi.example.com/login成功sessioncookie也返回client.example.com并且可以访问GET服务,如api.example.com/secret受sessioncookie。发出不受sessioncookie保护的GET请求不是问题。Ultimately,thegoalhereistooauthenticateaclientsideapptoaRESTapiusingCORSwithalocalstradegy-