聚合物准备在IE11上启动,但在Firefox或Chrome上不启动
Polymer-ready fires on IE11 but not on Firefox or Chrome
我遇到了一个意想不到的问题。
我有两页聚合物。两者在IE11上运行都很好,没有任何问题(除了性能缓慢)。现在,在Firefox和Chrome上,其中一个不起作用,永远不会发射聚合物,另一个工作得很好。如果有什么不同的话,人们会认为IE会是一个有麻烦的人。
与这种非激发行为相关,本页面在FF或Chrome上显示的唯一聚合物元素是主工具栏,以及其中的内容,仅此而已。我只是不知道下一步该做什么。
这是标题。第一个是来自网页,它在任何地方都有效,没有问题。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
<title>N-Adviser</title>
[... a bunch of element imports ...]
<script src="components/webcomponentsjs/webcomponents.js"></script>
<style shim-shadowdom>
[...some styling...]
</style>
<script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script>
</head>
这是一个糟糕的
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="headPortal" runat="server">
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes" />
<title>Portal</title>
<link rel="import" href="components/font-roboto/roboto.html" />
<link rel="import" href="components/polymer/polymer.html" />
[...a bunch of element imports...]
<link type="text/css" rel="stylesheet" href="Styles/LoginStyle.css" shim-shadowdom />
<script src="components/webcomponentsjs/webcomponents.js"></script>
<style></style>
<script src="http://code.jquery.com/jquery-1.7.js" type="text/javascript"></script>
</head>
除了其中一个从外部文件导入CSS之外,看不到任何差异,这应该无关紧要。
在所有的html 之后,它们都有自己的javascript代码
<script type="text/javascript">
$(document).ready(function () {
alert("docready");
});
window.addEventListener('polymer-ready', function (e) {
alert("polready");
[...]
</script>
两者都发射document.ready
,但只有第一个发射准备好的聚合物。有什么想法吗?
应该在导入html之前加载webcomponents.js。尝试将该脚本标记移动到所有导入之上(另请参阅https://www.polymer-project.org/docs/start/creatingelements.html)。这应该就是全部。
我想我能解释这种奇怪的行为。也许在导入文件的第一个示例中没有Polymer特定的功能,而在第二个示例中有(请注意,Polymer!=webcomponents.webcomponents.js包含Polymer特定功能)。因为IE11本身不支持web组件,所以它跳过html导入标记(它不知道它们),Polymer的polyfill在加载webcomponents.js后扫描文档并加载它们(因为这是polyfill中的一个函数)。
因为Chrome和FF确实支持web组件,所以在尚未加载webcomponents.js和Polymer函数之前,它们会"看到"html导入。因此它不起作用。
- 是否可以从在Firefox或IE的网页中运行的Javascript启动Windows进程
- 使用Bookmarklet在Firefox中为asp表单加载启动onclick事件
- 聚合物准备在IE11上启动,但在Firefox或Chrome上不启动
- JQuery:Submit事件未在FireFox上启动
- Mozilla Firefox加载项将不会启动
- 使用“nsIWebBrowserPersist saveURI”或Firefox扩展中的其他内容重新启动下载
- 点击通知后启动Firefox OS应用程序
- Firefox启动的扩展,在顶级中导入时的竞争条件
- PowerShell - 等待 Firefox 启动,运行 imacro 并等待它完成,关闭 Firefox
- 点击启动的视频不会在 Firefox 中启动,但在 Chrome 中会启动
- 开发 Firefox 扩展,在 Dom 启动时加载扩展
- Javascript onclick事件未在Firefox中启动
- 为什么Soundmanager 2没有在firefox中启动加载事件(23)
- Firefox在选择时启动,而不是在更改时启动
- 如何从Firefox扩展重新启动Mozila Firefox浏览器
- 如何在nsIProcess启动firefox失败时捕获错误
- 在不重新启动的情况下启动firefox扩展
- 在 Firefox 启动时启动 Firefox 扩展
- 最简单的方式启动Firefox,驱动第三方网站使用特权的nsI* api
- 在启动Firefox web控制台时将其设置为默认值