我正在使用自定义 Google 搜索来获取搜索查询的 Google 内容。
它在我的开发人员工具中显示了一些错误。该错误不影响结果意味着结果显示在我的 UI 中,但显示了一些错误。
错误是
加载“http://www.google.com/cse?q=web%20storage%20in%20html5&client=google-coop&h”时遇到无效的“X-Frame-Options” header …330&dt=1364365747827&u_w=1366&u_h=768&bs=1366,333&ps=1366,0&frm=0#master-1': 'ALLOWALL' 不是公认的指令。 header 将被忽略。
不安全的 JavaScript 试图从 URL 为 about:blank 的框架访问框架 URL 为 http://www.google.com/cse?q=web%20storage%20in%20html5&client=google-coop&h …330&dt=1364365747827&u_w=1366&u_h=768&bs=1366,333&ps=1366,0&frm=0#master-1。域、协议(protocol)和端口必须匹配。
加载“http://www.google.com/cse?q=web%20storage%20in%20html5&client=google-coop&h”时遇到无效的“X-Frame-Options” header …earch.aspx%3Fquery%3Dweb%2520storage%2520in%2520html5%26type%3D2#slave-1-1':'ALLOWALL' 不是公认的指令。 header 将被忽略。
这三个错误显示在我的 Developer 工具中。
我在aspx页面的代码
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script>
google.load('search', '1');
// get a custom search control & keep it in cseControl
// note: put your own custom search ID number here
var cseControl = new google.search.CustomSearchControl('009827885688477640989:igzwimalyta');
// open pages from search results clicks on the same page
cseControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
// when there are no matches, explain why
cseControl.setNoResultsString("Sorry, there are no pages in this web site that match all the search terms.");
// make the search field visible in div with ID 'cseDiv'
cseControl.draw('divGoogleResult');
cseControl.execute(userInput);
</script>
为什么会出现这个错误?如何消除这些错误?
最佳答案
why this error is showing?
- 因为 Google 的代码做了一些非标准的事情
- 因为 Google 的代码会尝试做不允许的事情。
- 这与1相同
how to remove these errors?
除非不使用 Google 的代码(或在 Google 找到一份从事该服务的工作!),否则您不能。
关于javascript - 自定义 Google 搜索 Ajax 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15653151/