New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render error in IE11 when deal with media query #1986
Comments
IE11 is really not a browser: ;)Allot of weard stuff can happen in IE11 with html2canvas (my experience anyway). Best way is to upgrade to edge or use other modern browsers. |
In fact, most of my page in IE11 works well with h2c. However, this problem drives me mad! :( |
I know the feeling :) |
I have found a workaround to solve this problem. It seems that the root cause of this problem is the cache in IE because the media query css can work well after clear cache. So before init h2c, I fetch all the link tag about css and add timestamp after the href. As a result, when h2c refetch these static resources, it will fetch from server instead of cache.
|
I also have met the same problem, have you solved this problem? |
I've been struggling with this issue, and while as reported above the previous solutions don't seem to fix the issue with the current codebase I have found a place to put the code that does resolve the issue. rather than doing the width + 1 hack before the close() call I've done something similar just before the return inside the iframe loader promise, here: html2canvas/src/dom/document-cloner.ts Line 100 in 3982df1
So that fragment now looks like this:
the parseInt is to avoid setting the width by string concatenation, which multiplies the width by 10x which is overkill when we're just trying to force a re-render. I've not yet rolled this out to production so there could yet be side effects that I've not caught in my testing, but things look promising so far. |
Bug reports:
I have encountered a similiar problem with #1451 in 1.0.0-rc3. I have some media query css such as
In Chrome and Edge, the render result is perfect. But in IE11, the result looks like in small screen. The width of div with media query matches css in
@media screen and (max-width: 980px) {}
.Then I revise the library following the direction in https://stackoverflow.com/questions/31793507/html2canvas-renders-page-with-wrong-layout-in-ie11-whed-devtools-not-opened#comment92407156_31800273 that revise https://github.com/niklasvh/html2canvas/blob/master/src/dom/document-cloner.ts#L429 to
cloneIframeContainer.width = (bounds.width + 1).toString();
. But the situation is not changed.One more werid thing. The situation in https://stackoverflow.com/questions/31793507/html2canvas-renders-page-with-wrong-layout-in-ie11-whed-devtools-not-opened#comment92407156_31800273 also happened to me. When open devtools, the render works well. With further research. I found that if I open the config
Always refresh from server
, it can work well, but without that the media query will go wrong.The text was updated successfully, but these errors were encountered: