以上就是给各位分享UncaughtDOMException:Blockedaframewithorigin"null"fromaccessingacross-origin...,同时本文还将给你拓展A
以上就是给各位分享Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin...,同时本文还将给你拓展Access-Control-Allow-Origin 不允许 Origin null、AngularJS:无法加载资源:Chrome中的Access-Control-Allow-Origin不允许使用Origin null、Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.、Blocked a frame with origin XXX from accessing a cross-origin 。iframe跨域问题等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin...
- Access-Control-Allow-Origin 不允许 Origin null
- AngularJS:无法加载资源:Chrome中的Access-Control-Allow-Origin不允许使用Origin null
- Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
- Blocked a frame with origin XXX from accessing a cross-origin 。iframe跨域问题
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin...
工具环境:Layui 框架下使用VS Code进行Chrome 调试。
问题描述:当Chrome浏览器使用iframe页面调用其他页面时会提示:"Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame"。
但是IE和Edge是没有问题的。
原因:Chrome 认为其跨域不安全。
解决办法:launch.json里面加上配置:
1 "version": "0.2.0",
2 "configurations": [
3 {
4 "name": "使用本机 Chrome 调试",
5 "type": "chrome",
6 "request": "launch",
7 "file": "${workspaceRoot}/index.html",
8 //"url": "http://mysite.com/index.html", //使用外部服务器时,请注释掉 file, 改用 url, 并将 useBuildInServer 设置为 false "http://mysite.com/index.html
9 "runtimeExecutable": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", // 改成您的 Chrome 安装路径
10 "sourceMaps": false,
11 "webRoot": "${workspaceRoot}",
12 // "preLaunchTask":"build",
13 "userDataDir":"${tmpdir}",
14 "port":5433
15 ,"runtimeArgs": [
16 " --disable-web-security" //跨域访问,不安全,仅本地测试
17 ]
18 }
19 ]
Access-Control-Allow-Origin 不允许 Origin null
我制作了一个小的 xslt 文件来创建一个名为 weather.xsl 的 html 输出,代码如下:
<!-- DWXMLSource="http://weather.yahooapis.com/forecastrss?w=38325&u=c" -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="yweather"
xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/">
<img src="{/*/*/item/yweather:condition/@text}.jpg"/>
</xsl:template>
</xsl:stylesheet>
我想将 html 输出加载到 html 文件中的 div 中,我尝试使用 jQuery 执行如下操作:
<div id="result">
<script type="text/javascript">
$('#result').load('weather.xsl');
</script>
</div>
但我收到以下错误:Access-Control-Allow-Origin 不允许 Origin null。
我已经阅读了有关向 xslt 添加标头的信息,但我不知道该怎么做,所以任何帮助都将不胜感激,如果无法以这种方式加载 html
输出,请提供有关其他方法的建议这样做会很棒。
AngularJS:无法加载资源:Chrome中的Access-Control-Allow-Origin不允许使用Origin null
我正在使用AngularJS v1.1.5,并尝试使用ng-include加载模板,
Failed to load resource: Origin null is not allowed by Access-Control-Allow-Origin. file:///E:/apps/partials/holidayList.htmlXMLHttpRequest cannot load file:///E:/apps/partials/holidayList.html. Origin null is not allowed by Access-Control-Allow-Origin.
我已经尝试了chrome的命令行选项,对我来说禁用该策略不起作用,并且我不需要命令行选项,我需要在anguarjs文件中进行任何编辑
答案1
小编典典您需要使用以下命令打开镶边。(按窗口+ R)
Chrome.exe --allow-file-access-from-files
注意:您的镶边不能打开。运行此命令时,Chrome会自动打开。
如果要在命令提示符下输入此命令,请选择chrome安装目录,然后使用此命令。
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
背景
运行时代码报错:
selenium.common.exceptions.WebDriverException: Message: An unkNown server-side error occurred while processing the command. Original error: Could not sign with default certificate. Original error Command ''C:\\Program Files\\Java\\jdk1.8.0_131\\bin\\java.exe' -jar 'C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-adb\\jars\\sign.jar' 'C:\\Program Files\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-uiautomator2-server\\apks\\appium-uiautomator2-server-debug-androidTest.apk' --override' exited with code 1
问题分析
该问题主要是证书签名错误,猜测是用了新版appium装了驱动之后,又换成旧版本的appium这个时候会出现两者的签名证书不一致导致认证错误
解决方案一
就是把appium-desktop换成新的,或者进入设备-应用管理-搜索 appium 相关程序,手动卸载掉再执行一遍脚本
解决方案二
还有一种解释是运行appium-server时没有足够的权限,使用管理员去打开appium-server可以解决这个问题
Blocked a frame with origin XXX from accessing a cross-origin 。iframe跨域问题
在前端开发的过程中,我们常常会用到iframe去在我们的页面中引用一个子页面,而父子页面又常常会有交互。在同域情况下,子页面如果想要访问父页面中的window对象中的方法的话,直接在当前页面中使用window.parent就可以啦。但是在跨域情况下就会受到种种限制。
如图所示,我用node在本地起了2个server,端口号分别是:8124和8123。
下面,我在server1页面中通过iframe的方式将server2的页面引入,如图:
我们在子页面“server2”中打印一下当前页面和父页面的window对象,如图:
如图所示,在子页面中,父页面window对象中绝大多数方法和属性都已经拿不到了。这其实就是跨域造成的限制。
比如说我们在父页面中定义了一个sessionStorage,
然后在子页面中访问父页面的sessionStorage:
不出所料,报了一个跨域的错误
这就是由于跨域导致了子页面无法调用和访问父页面中的属性和方法,这给我们的业务开发带来了很大的影响。解决这种问题最好的办法就是将子页面和父页面放到同一域名下,那么跨域问题自然就解决了。
可是在实际业务中,由于客观原因,我们往往无法做到将父页面和子页面放倒同一域名下。那有没有其他方法可以在跨域的情况下,依然让子页面调用父页面中的方法呢?当然是有的!
经过在网上查阅相关资料文章,我大体得到两种方法,第一种是“代理页面”法,第二种是通过“postMessage”法。
下文将详细介绍“代理页面”法
何为“代理页面法”?简言之就是,在父页面的同域下,放一个代理页面,代替子页面去执行调用父页面中方法的操作。
文字描述略显枯燥,接下来我用图片分步讲解这一过程:
第一步:我在父页面的同域下新建了一个代理页面:iframe.html,在这个代理页面中注册一个“window.onload”监听事件,当代理页面被加载的时候,执行window.top对象上的“excute”方法。
第二步:在父页面中定义将要被执行的excute方法,该方法打印出当前页面中的sessionStorage(之前子页面想要做的事)
第三步:在子页面中定义一个方法,当触发该方法时会在子页面中create一个看不到的iframe,并将代理页面的地址,赋给这个iframe。
经过这三个步骤,代理页面的方式访问父页面window对象的方法已经完成了:
此时,点击子页面中的“跨域”按钮,就会把父页面中的sessionStorage打印出来。
整理一下,其实思路如图所示:
当在子页“http://localhost:8123/index2”中触发事件时,创建一个iframe,iframe引入代理页“http://localhost:8124/iframe.html”,代理页在加载时通过“window.top.excute”执行父页“http://localhost:8124/index1.html”中的excute方法。这样就实现了在子页面中与父页面跨域进行交互!
引自
https://www.jianshu.com/p/9d90d3333215
关于Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin...的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于Access-Control-Allow-Origin 不允许 Origin null、AngularJS:无法加载资源:Chrome中的Access-Control-Allow-Origin不允许使用Origin null、Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.、Blocked a frame with origin XXX from accessing a cross-origin 。iframe跨域问题等相关内容,可以在本站寻找。
本文标签: