Opera:.js文件无法加载

时间:2023-02-06 12:20:27

I have a page that calls a script in the header, like so:

我有一个页面调用标题中的脚本,如下所示:

<script type="text/javascript" src="http://www.discoverfire.net/analytics/l/a.js"></script>

(Note you will NOT be able to load this script as it is DNSd locally as a staging domain)

(注意,您将无法加载此脚本,因为它在本地作为暂存域进行DNSd)

Very Simple.

Firefox, IE, Chrome all have no problem with this basic, square-one feature.

Firefox,IE,Chrome在这个基本的方形功能上都没有问题。

Opera, however, refuses to load the script. Any variables or functions in it are "undefined" and in dragonfly, the script tag is shown in the DOM, but the "Script" tab says "No script files found."

但是,Opera拒绝加载脚本。其中的任何变量或函数都是“未定义的”,在dragonfly中,脚本标记显示在DOM中,但“脚本”选项卡显示“未找到脚本文件”。

I go to google and find random pages, their external .js files seem to work just fine.

我去谷歌找到随机页面,他们的外部.js文件似乎工作得很好。

Any idea why Opera hates me? Is there a security/javascript thing I am missing?

知道为什么Opera讨厌我吗?我缺少安全/ javascript的东西吗?

A few things that may be relevant, but really should make no difference:

一些可能相关的事情,但实际上应该没有区别:

  • The script is on a different domain than the page.
  • 该脚本与页面位于不同的域中。

  • The script is only available on my local network. The domain is DNS'd locally for staging, from outside the network it points somewhere else. Does Opera have a setting to secretly use an external DNS server?
  • 该脚本仅在我的本地网络上可用。该域在本地DNS用于登台,从网络外部指向其他地方。 Opera有设置秘密使用外部DNS服务器吗?

  • The script works on every other browser I have.
  • 该脚本适用于我拥有的每个其他浏览器。

  • The problem isn't in the script content. I've reduced it to a single line with an alert and it simply won't work in Opera.
  • 问题不在脚本内容中。我已经将它减少到一个带有警报的行,它在Opera中无法工作。

Update:

OK, the problem seems to be how Opera treats the domain.

好吧,问题似乎是Opera如何对待域名。

I have moved the script to several other domains, and it DOES work just fine. I've moved it to several paths on the locally DNS'd domain, and it won't work from anywhere on that domain.

我已将脚本移动到其他几个域,它的工作正常。我已将其移至本地DNS'd域上的多个路径,并且无法在该域上的任何位置工作。

This leads me to believe that the problem is that Opera can't, or won't, load the script from this domain for some reason.

这让我相信问题是Opera出于某种原因不能或不会从这个域加载脚本。

Strangely, there seems to be no problem loading pages and other resources from the domain, the problem lies in .js files only.

奇怪的是,从域中加载页面和其他资源似乎没有问题,问题在于.js文件。

The domain is registered, but parked. We DNS'd it locally so we can use it for staging/testing, and that may be messing with Opera somehow with JS security.

域名已注册,但已停放。我们在本地DNS它,所以我们可以用它来进行暂存/测试,这可能会以某种方式搞乱Opera安全性。

I could be wrong though - I really have no idea. If anyone else has one, I'd love to hear it.

我可能错了 - 我真的不知道。如果其他人有一个,我很乐意听到。

Update 2:

Regarding Dragonfly and the error console/developer tools, they don't say anything about the script at all. There are plenty of Undefined Variable errors for variables and functions that should be present from the script, but other than that, no errors. Oddly, the script tag does show up in the DOMM, but if I click on the Scripts tab, it says "No Scripts Found".

关于Dragonfly和错误控制台/开发人员工具,他们根本不会对脚本说什么。对于应该在脚本中出现的变量和函数,存在大量未定义变量错误,但除此之外,没有错误。奇怪的是,脚本标记确实显示在DOMM中,但如果我单击“脚本”选项卡,则会显示“找不到脚本”。

Update 3:

There is no blocked content, so we can at least rule out that setting.

没有被阻止的内容,因此我们至少可以排除该设置。

8 个解决方案

#1


You may want to see if its ad blocker is getting in the way. Your URL contains the text "analytics," which may be part of a "block this" pattern. I know some block Google analytics through Opera. An easy test for this may be to try moving your .js to a different path on the host.

您可能想看看它的广告拦截器是否会妨碍您。您的网址包含文本“analytics”,这可能是“阻止此”模式的一部分。我知道有些通过Opera阻止Google分析。一个简单的测试可能是尝试将.js移动到主机上的不同路径。

#2


Have you checked Opera's error console? Tools > Advanced > Error Console It should provide information on why it won't load or if there another error of some kind.

你检查过Opera的错误控制台吗?工具>高级>错误控制台它应该提供有关它不会加载的原因或是否存在某种其他错误的信息。

#3


Like Jacob suggested, you should check if it isn't blocked. To do this:

像雅各布建议的那样,你应该检查它是否被阻挡。去做这个:

  • Right-click on your page
  • 右键单击您的页面

  • Select "Block Content..." in the context menu
  • 在上下文菜单中选择“阻止内容...”

  • At the top of the screen, click the "Details..." button
  • 在屏幕顶部,单击“详细信息...”按钮

  • You should see the URL's that are blocked on the current page
  • 您应该会看到当前页面上阻止的URL

#4


You should ask in the Opera Forums. I had some problems with Opera in the past and they answered quickly.

你应该在Opera论坛上问一下。我过去在Opera中遇到了一些问题,他们很快回答。

#5


Is the host serving the correct mime type of the JavaScript file. It's not a commonly known fact but the type=text/javascript attribute is actually ignored by browsers as it trusts that the server is specifying the correct type.

主机是否提供JavaScript文件的正确mime类型。这不是一个众所周知的事实,但是浏览器实际上忽略了type = text / javascript属性,因为它信任服务器指定了正确的类型。

Additionally the mime type of text/javascript is actually wrong when it comes to JavaScript, the actual JavaScript mime type is application/ecmascript (if I recall correctly, it may be application/javascript though). If you don't believe me you should have a look here where I had more information and linked off to the Douglas Crockfords videos where he discussed the mime type.

另外,当涉及到JavaScript时,mime类型的text / javascript实际上是错误的,实际的JavaScript mime类型是application / ecmascript(如果我没记错的话,它可能是application / javascript)。如果你不相信我,你应该看看我有更多信息,并链接到道格拉斯Crockfords视频,他讨论了mime类型。

#6


I had something similar recently - opera would just not run a script on an external server... nor if I downloaded it and had it on localhost. It only ran when copy/pasted between script tags into the html page.

我最近有类似的东西 - 歌剧不会在外部服务器上运行脚本......也不是我下载它并在localhost上运行它。它仅在脚本标记之间复制/粘贴到html页面时运行。

It turned out that the script was encoded with UTF-16 and that was somehow confusing the browser. When I converted it to UTF-8, everything ran fine.

事实证明,脚本是用UTF-16编码的,这在某种程度上让浏览器感到困惑。当我把它转换成UTF-8时,一切都运行良好。

So, just in case and if you still have that problem, check out the encoding settings...

所以,以防万一,如果你还有这个问题,请查看编码设置......

#7


I had the exact same issue, tying to load a script from a localhost/development server into a page, hosted on the public server at no avail. The only way I managed the script to load in Opera was to save a copy of the page into a location on the same development server and use the tag to refer to the original domain to get the page's .css and .js linked files. That worked. Looks like Opera doesn't like to mix public and localhost domains, but handles localhost without complaints.

我有完全相同的问题,想要将一个脚本从localhost /开发服务器加载到一个页面,托管在公共服务器上无济于事。我在Opera中管理脚本的唯一方法是将页面副本保存到同一开发服务器上的某个位置,并使用标记引用原始域以获取页面的.css和.js链接文件。那很有效。看起来Opera不喜欢混合使用公共域名和localhost域名,但是无需投诉即可处理localhost。

#8


what you're seeing is probably Opera's security precaution against the so-called "phish pharm" attacks: cross-network protection. You can not mix content from a public server and content from a local server.

您所看到的可能是Opera针对所谓的“网络钓鱼”攻击的安全预防措施:跨网络保护。您不能混合来自公共服务器的内容和来自本地服务器的内容。

Have a look at my answer here for a workaround:

请看一下我的答案,找出解决方法:

Opera won't load some JavaScript files

Opera不会加载一些JavaScript文件

#1


You may want to see if its ad blocker is getting in the way. Your URL contains the text "analytics," which may be part of a "block this" pattern. I know some block Google analytics through Opera. An easy test for this may be to try moving your .js to a different path on the host.

您可能想看看它的广告拦截器是否会妨碍您。您的网址包含文本“analytics”,这可能是“阻止此”模式的一部分。我知道有些通过Opera阻止Google分析。一个简单的测试可能是尝试将.js移动到主机上的不同路径。

#2


Have you checked Opera's error console? Tools > Advanced > Error Console It should provide information on why it won't load or if there another error of some kind.

你检查过Opera的错误控制台吗?工具>高级>错误控制台它应该提供有关它不会加载的原因或是否存在某种其他错误的信息。

#3


Like Jacob suggested, you should check if it isn't blocked. To do this:

像雅各布建议的那样,你应该检查它是否被阻挡。去做这个:

  • Right-click on your page
  • 右键单击您的页面

  • Select "Block Content..." in the context menu
  • 在上下文菜单中选择“阻止内容...”

  • At the top of the screen, click the "Details..." button
  • 在屏幕顶部,单击“详细信息...”按钮

  • You should see the URL's that are blocked on the current page
  • 您应该会看到当前页面上阻止的URL

#4


You should ask in the Opera Forums. I had some problems with Opera in the past and they answered quickly.

你应该在Opera论坛上问一下。我过去在Opera中遇到了一些问题,他们很快回答。

#5


Is the host serving the correct mime type of the JavaScript file. It's not a commonly known fact but the type=text/javascript attribute is actually ignored by browsers as it trusts that the server is specifying the correct type.

主机是否提供JavaScript文件的正确mime类型。这不是一个众所周知的事实,但是浏览器实际上忽略了type = text / javascript属性,因为它信任服务器指定了正确的类型。

Additionally the mime type of text/javascript is actually wrong when it comes to JavaScript, the actual JavaScript mime type is application/ecmascript (if I recall correctly, it may be application/javascript though). If you don't believe me you should have a look here where I had more information and linked off to the Douglas Crockfords videos where he discussed the mime type.

另外,当涉及到JavaScript时,mime类型的text / javascript实际上是错误的,实际的JavaScript mime类型是application / ecmascript(如果我没记错的话,它可能是application / javascript)。如果你不相信我,你应该看看我有更多信息,并链接到道格拉斯Crockfords视频,他讨论了mime类型。

#6


I had something similar recently - opera would just not run a script on an external server... nor if I downloaded it and had it on localhost. It only ran when copy/pasted between script tags into the html page.

我最近有类似的东西 - 歌剧不会在外部服务器上运行脚本......也不是我下载它并在localhost上运行它。它仅在脚本标记之间复制/粘贴到html页面时运行。

It turned out that the script was encoded with UTF-16 and that was somehow confusing the browser. When I converted it to UTF-8, everything ran fine.

事实证明,脚本是用UTF-16编码的,这在某种程度上让浏览器感到困惑。当我把它转换成UTF-8时,一切都运行良好。

So, just in case and if you still have that problem, check out the encoding settings...

所以,以防万一,如果你还有这个问题,请查看编码设置......

#7


I had the exact same issue, tying to load a script from a localhost/development server into a page, hosted on the public server at no avail. The only way I managed the script to load in Opera was to save a copy of the page into a location on the same development server and use the tag to refer to the original domain to get the page's .css and .js linked files. That worked. Looks like Opera doesn't like to mix public and localhost domains, but handles localhost without complaints.

我有完全相同的问题,想要将一个脚本从localhost /开发服务器加载到一个页面,托管在公共服务器上无济于事。我在Opera中管理脚本的唯一方法是将页面副本保存到同一开发服务器上的某个位置,并使用标记引用原始域以获取页面的.css和.js链接文件。那很有效。看起来Opera不喜欢混合使用公共域名和localhost域名,但是无需投诉即可处理localhost。

#8


what you're seeing is probably Opera's security precaution against the so-called "phish pharm" attacks: cross-network protection. You can not mix content from a public server and content from a local server.

您所看到的可能是Opera针对所谓的“网络钓鱼”攻击的安全预防措施:跨网络保护。您不能混合来自公共服务器的内容和来自本地服务器的内容。

Have a look at my answer here for a workaround:

请看一下我的答案,找出解决方法:

Opera won't load some JavaScript files

Opera不会加载一些JavaScript文件