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
Uncaught (in promise) Provided element is not within a Document #1313
Comments
The element you are trying to render is not within the Document DOM |
So how to fix this issue? 0.5 is fine but when I upgrade to 1 I got this error |
Please share an example on jsfiddle |
I have tried to load the html2canvas js (version 1) and my app js after the HTML body and this issue got fixed for me. |
Does anyone got a fix for this issue, I have the same problem while using in ASP.Net MVC cshtml page. |
If you use jQuery to find DIV use |
But I am unable to take image of google map using html2canvas(all map image is not coming), Can anyone help me out how to do the same in cshtml ??? |
@cjcortez @RaghavPrabhu does smartbepl's solution above fix it for you presuming you are using jQuery or some other library that provides a list of elements instead of a single |
This works for me! |
thanks it worked |
@jeremielodi Thank you, this was driving me nuts! |
I tried code similar to the above, but maybe the error I'm getting isn't quite related: Uncaught (in promise) undefined... Promise rejected (async) |
I was having the exact same problem - I wanted to call HTML2Canvas on button click. No matter how I wrote the HTML2Canvas call, I would get an "Uncaught (in promise) undefined...Promise rejected (async)" error. Finally, I learned a little bit about how promises work and found the solution was adding a catch:
Word of warning, I'm a total javascript novice and understand very little about how promises work. My code worked fine without the .catch() if I used it outside of a function. I'm assuming that somehow, when you encapsulate it, it no longer has the correct DOM access and the promise fails. |
@ikemike this can help you <html>
<head>
<title>html2canvas</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"></script>
<style type='text/css'>
#test {
height: 40px;
width: 40px;
border: 1px solid #001;
background: red
}
</style>
</head>
<body>
<div id='test' >
</div>
<img src='' alt='' id='img' />
<script>
html2canvas($('#test').get(0)).then(function (canvas) {
var base64encodedstring = canvas.toDataURL("image/jpeg", 1);
$('#img').attr('src', base64encodedstring);
});
</script>
</body>
</html> |
@niklasvh with latest version of html2canvas I am getting Uncaught (in promise): undefined error. Can you please help me. |
ths,it works |
This works fine for me:
|
in chrome, it works fine, but in IE11, doesn't work... T_T;
|
@bandacs did you find a solution to this? I'm getting exact error as your screen shot. |
I'm using 1.0 alpha 12 release and I'm having the same problem. I've tried all of these solutions. I've tried this solution by @smartbepl I tried this by @jeremielodi I also tried leandrocgsi solution and tried adding a catch as @ikemike suggest. To simplify it and ensure all elements are loaded on the DOM, I place a function called take_screenshot(). function take_screenshot() |
I have exactly the same issue that faced by #1313 (comment) |
why i failed in cheerio?
|
There is another calling convention now. |
What is the meaning of this error? and how to fix it
The text was updated successfully, but these errors were encountered: