javascript - jQuery TypeError "Cannot call method ' toLowerCase' 未定义”(函数 uaMatch)

标签 javascript jquery subdomain

我在 jQuery 方面遇到了一个非常奇怪的问题:

我有一个网站(带有 Flask):http://localhost:5000/,它工作得很好。现在我已经设置了一个子域,编辑了我的 /etc/hosts (我添加了 127.0.0.1 fonts.localhost),子域使用完全相同的 html (甚至更少)但是当我加载该网站时,jQuery 给出了这个错误: 未捕获类型错误:无法调用未定义的方法“toLowerCase”。它来自未压缩的 jQuery 1.7.2884 行中的函数 uaMatch。文件。传递给函数的参数必须是未定义的,uaMatch 仅使用 userAgent 调用一次(第 925 行),userAgent 在第 75 行赋值: userAgent = navigator.userAgentnavigator.userAgent"Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19" (根据调试控制台)。

所以我真的不明白为什么会出现这个错误,它只发生在子域上。 fonts.localhost:5000 的重要 html。

<!doctype html>
<title>test</title>
<meta charset=utf-8>
<link rel=stylesheet type=text/css href="http://localhost:5000/static/style.css">
<link rel=stylesheet type=text/css href="http://localhost:5000/static/bootstrap.min.css">
<script type=text/javascript src="http://localhost:5000/static/jquery-1.7.2.min.js"></script>
<body>
    …
</body>

编辑: 它也不适用于未压缩的 jQuery(我还包含了托管在 google 上的 jQuery 文件进行测试,同样的错误)

最佳答案

天哪,我终于发现了错误,好像 jQuery 无法处理没有 TLD 的域,我将主机条目从 127.0.0.1 fonts.localhost 更改为 127.0.0.1 fonts.localhost.localdomain,在此更改后 jQuery 起作用了。值得报告错误吗?

关于javascript - jQuery TypeError "Cannot call method ' toLowerCase' 未定义”(函数 uaMatch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10463366/

相关文章:

javascript - 使用 '>' 字符使用 javascript 拆分字符串

javascript - 仅向 Laravel 中的登录用户显示按钮

Javascript 函数数组删除项目

css - Rails 用户站点自定义选项表单更改 CSS?

javascript - Websockets 仅在 Socket.io 1.3.4 中传输

javascript - jQuery .on( 点击类名 )

javascript - 如何在 php 代码中使用 jQuery 变量?

javascript - 复选框单击事件中的 event.stopPropagation 是否会阻止 IE8 及更早版本中触发更改事件?

python - 如何在 Python 中获取计算机的完全限定域名?

subdomain - 如何在 Plesk 11 中创建子域的域别名?