草庐IT

Strict-Transport-Security

全部标签

javascript - phonegap + ionic 使用 Content-Security-Policy 加载 maps.googleapis.com,如何?

我尝试了很多加载谷歌地图和firebaseio的方法,但都没有成功:这就是我现在拥有的:我得到:Refusedtoloadthescript'https://maps.googleapis.com/maps/api/js?libraries=places'becauseitviolatesthefollowingContentSecurityPolicydirective:"script-src'self'https://maps.googleapis.com/*'unsafe-inline''unsafe-eval'".Refusedtoloadthescript'https://t

javascript - Cordova 错误 : Refused to execute inline script because it violates the following Content Security Policy directive

我正在学习将Cordova与jquerymobile结合使用,但出现以下错误:RefusedtoexecuteinlinescriptbecauseitviolatesthefollowingContentSecurityPolicydirective:"default-src'self'data:gap:https://ssl.gstatic.com'unsafe-eval'".Eitherthe'unsafe-inline'keyword,ahash('sha256-iacGaS9lJJpFDLww4DKQsrDPQ2lxppM2d2GGnzCeKkU='),oranonce('n

javascript - 如何通过 Content-Security-Policy 允许 `javascript:void(0)` 在 HTML 元素属性中使用?

我希望能够做到或确保即使处理程序未能阻止默认操作也不会发生任何事情。我应该如何声明允许使用Content-Security-PolicyHTTP响应header而不求助于unsafe-eval? 最佳答案 我最近将CSP策略应用于一个巨大的VUE项目,方法是将元header添加到index.html。GoogleChrome会打印关于javascript:的警告链接,但除此之外没有其他任何事情发生。我所做的只是删除href="javascript:属性,并添加了一个样式来保持游标样式:a:hover{cursor:pointer;}

javascript - 'use strict' 和只读属性的奇怪行为

OntheMDNstrictmodereferencepage它说Anyassignmentthatsilentlyfailsinnormalcode(assignmenttoanon-writableproperty,assignmenttoagetter-onlyproperty,assignmenttoanewpropertyonanon-extensibleobject)willthrowinstrictmode所以,使用他们的例子,做类似下面的事情会抛出TypeError"usestrict";varobj1={};Object.defineProperty(obj1,"x"

javascript - CORS plugin/--disable-web-security 如何在浏览器上工作?

我确定我不是唯一使用过/使用过CORSplugins的人对于浏览器或--disable-web-security标志,同时对外部(甚至内部)API端点进行API调用。我使用这个插件来进行谷歌地图相关的API调用。但在同一个应用程序中,ParseSDKAPI调用不需要CORS或--disable-web-security标志。我的问题是:为什么这些端点的行为不同以及CORS插件如何解决问题(即使我们无法控制这些API)?提前致谢。 最佳答案 好吧,那个插件的所作所为是非常不负责任的;它实际上禁用了同源策略,该策略强制特定源上的网站只能

javascript - 构造函数中的 "use strict"是否扩展到原型(prototype)方法?

我试图弄清楚“usestrict”的定义是否扩展到构造函数的原型(prototype)方法。示例:varMyNamespace=MyNamespace||{};MyNamespace.Page=function(){"usestrict";};MyNamespace.Page.prototype={fetch:function(){//doIneedtouse"usestrict"hereagain?}};根据Mozilla您可以将其用作:functionstrict(){"usestrict";functionnested(){return"AndsoamI!";}return"Hi

javascript - `jshint globalstrict: true` 与 'use strict' 的用途

在阅读JavaScript源代码时,我经常会在顶部看到这两行代码。/*jshintglobalstrict:true*/'usestrict';现在,我很清楚'usestrict';的用途了。有人能告诉我为什么要包含jshintglobalstrict吗? 最佳答案 JSHint(从JSLint派生)是一个流行的“lintchecker”,它运行在JavaScript代码上。它不执行或修改代码,而是对其进行分析并报告它发现的各种不同的潜在错误或不良做法。如果您在JavaScript文件的顶部(在任何JavaScript函数之外)有'

javascript - JS : What is 'this' coercion? use-strict 和那个有什么关系?

我在网站上阅读了以下内容:Use-stricthasanadvantage.Iteliminatesthiscoercion.Withoutstrictmode,areferencetoathisvalueofnullorundefinedisautomaticallycoercedtotheglobal.Thiscancausemanyheadfakesandpull-out-your-hairkindofbugs.Instrictmode,referencingaathisvalueofnullorundefinedthrowsanerror.这到底是什么意思?use-strict

JavaScript 'use strict' ;内部函数

在ChromeDevConsole中测试了一些js代码,我有点困惑。我知道在严格模式中,当引用this关键字时不是对象方法的函数应该接收undefined而不是全局对象.functiontest(){"usestrict";returnthis===undefined;}test();输出假。"usestrict";functiontest(){returnthis===undefined;}test();仍然错误。(functiontest(){"usestrict";returnthis===undefined;}());输出真。只是想澄清一下。ʕ•ᴥ•ʔ我是js新手。

javascript - 将 'use strict' 放在 Browserify 包中的什么位置

在Browsersifybundle(包含来自许多文件的许多模块)中,usestrict应该出现在哪里以确保整个bundle在严格模式下运行? 最佳答案 当您需要以统一的方式更改browserify输出时,答案通常是使用转换。strictify似乎可以满足您的需求。 关于javascript-将'usestrict'放在Browserify包中的什么位置,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com