jQuery 可以让 Excanvas 在 IE 8 中工作吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/941170/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Possible to get Excanvas to work in IE 8?
提问by AndreMiranda
I used to work on a jQuery plugin named 'BeautyTips' and it was working just fine. But, since I've installed IE 8, this plugin stop working because it needs Excanvas to make IE draw the vectors, images etc.
我曾经在一个名为“BeautyTips”的 jQuery 插件上工作,它工作得很好。但是,由于我安装了 IE 8,这个插件停止工作,因为它需要 Excanvas 来让 IE 绘制矢量、图像等。
I've tried to download the newer version of Excanvas but it's not working at all...
我试图下载较新版本的 Excanvas,但它根本不起作用......
采纳答案by Jeff Lamb
Try appending the canvas element to the document before initializing it using excanvas:
在使用 excanvas 初始化之前,尝试将 canvas 元素附加到文档中:
var foo = document.getElementById("targetElementID");
var canvas = document.createElement('canvas');
canvas.setAttribute("width", 620);
canvas.setAttribute("height", 310);
canvas.setAttribute("class", "mapping");
foo.appendChild(canvas);
canvas = G_vmlCanvasManager.initElement(canvas);
回答by Javier
The new 'standards' mode of IE8 turns off some nonstandard features. Among them VML, which is used by excanvas. I just set for IE7 'standards' mode, so it still works.
IE8 的新“标准”模式关闭了一些非标准功能。其中VML,就是excanvas使用的。我刚刚设置为 IE7“标准”模式,所以它仍然有效。
<meta http-equiv="X-UA-Compatible" content="IE=7" />
Frustrating, but i don't know of any advantage brought up by IE8.
令人沮丧,但我不知道 IE8 带来的任何优势。
回答by Ronald B.
Yes, I have got excanvas working in IE8 standards mode (only tested for the usage we required). In the function CanvasRenderingContext2D_I commented out the line:
是的,我已经让 excanvas 在 IE8 标准模式下工作(仅针对我们要求的使用进行了测试)。在CanvasRenderingContext2D_函数中,我注释掉了这一行:
//el.style.overflow = 'hidden';//fix IE8
//el.style.overflow = 'hidden';//fix IE8
The width and height of the node object el was 0px by 0px, so not setting the overflow to hidden made the rendered item visible.
节点对象 el 的宽度和高度为 0px x 0px,因此不将溢出设置为隐藏会使渲染项目可见。
I did change the order of the creation of the canvasPieTimera bit, to get the required result. I hope this is helpful.
我确实稍微更改了canvasPieTimer的创建顺序,以获得所需的结果。我希望这是有帮助的。
回答by fbuchinger
Are you sure you have the most recent version of excanvas.js installed? (released in March 2009, hosted on the new Google Code project page)
您确定安装了最新版本的 excanvas.js 吗?(2009 年 3 月发布,托管在新的 Google 代码项目页面上)
I used the Beauty Tips Plugin in IE8 and AFAIK it worked in IE8 native mode.
我在 IE8 和 AFAIK 中使用了 Beauty Tips Plugin,它在 IE8 本机模式下工作。
回答by jeff Walters
The latest bt plugin version fixes this issue for me.
最新的 bt 插件版本为我解决了这个问题。
回答by Markus
Appending a canvas tag as a string of html with jquery doesn't work with the new version of excanvas. You have to use document.createElement('canvas') first.
使用 jquery 将画布标记作为 html 字符串附加到新版本的 excanvas 中不起作用。您必须先使用 document.createElement('canvas') 。
回答by Salmonela
if anyone still have this issue: Beauty Tips version 0.9.5 fixes this issue. however if you have to use earlier version (like i do, as the new version introduced an issue of tips being closed prematurely in my page), you should replace line 530 with these lines:
如果有人仍然有这个问题:Beauty Tips 0.9.5 版修复了这个问题。但是,如果您必须使用早期版本(就像我一样,因为新版本在我的页面中引入了提示过早关闭的问题),您应该将第 530 行替换为以下几行:
var canvas = document.createElement('canvas');
$(canvas).attr('width', (numb($text.btOuterWidth(true)) + opts.strokeWidth*2)).attr('height', (numb($text.outerHeight(true)) + opts.strokeWidth*2)).appendTo($box).css({position: 'absolute', top: $text.btPosition().top, left: $text.btPosition().left, zIndex: opts.boxzIndex});
hope it helps.
希望能帮助到你。