NS_ERROR_FAILURE in Firefox on setting font of canvas inside a hidden iframe

只愿长相守 提交于 2020-01-15 03:22:07

问题


I am trying to create a text editor using a canvas.

To place the cursor at the right position I need to calculate the width of every character.

I am caching the width of each character on initial load.

This works fine on Firefox when launched directly but throws an error (NS_ERROR_FAILURE) when launched inside an iframe whose parent is hidden.

I've narrowed down this case in a fiddle here.

Can anyone help me out with the cause of this issue?


回答1:


You can't have an iframe set to display:none. If you really think you need an invisible iframe you can do this:

.frame-wrapper {
  z-index: -1231231;
  position:absolute;
  top:0; left:0;
  height:1px; width:1px;
  opacity:0;
}

But if all you're doing is running an invisible canvas you can do that in javascript.



来源:https://stackoverflow.com/questions/48303223/ns-error-failure-in-firefox-on-setting-font-of-canvas-inside-a-hidden-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!