Skip to content
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

QRious not found since upgrade Chrome to latest version #130

Open
Luigius opened this issue Aug 21, 2021 · 4 comments
Open

QRious not found since upgrade Chrome to latest version #130

Luigius opened this issue Aug 21, 2021 · 4 comments

Comments

@Luigius
Copy link

Luigius commented Aug 21, 2021

Hi,
My code was working fine until I updated chrome, since then this code returns:
new QRious
({
element: document.getElementById("qrcodecanvas"),
level: 'H',
padding: 0,
size: 250,
value: dataqr
});
Uncaught ReferenceError: QRious is not defined

the element is defined before the script code like this

I also tried to use canvas instead of img

Any suggestion?
Thanks
Luigi

@ROBERT-MCDOWELL
Copy link

did you try to create the object on window.onload ?

@ROBERT-MCDOWELL
Copy link

window.addEventListener("load",function(){
const head = document.getElementsByTagName('head')[0];
const qriousScript = document.createElement('script');
if(typeof(qriousScript.onreadystatechange) != "undefined"){
qriousScript.onreadystatechange = function(){
if(this.readyState == 'complete'){
build_something();
}
}
}else{
qriousScript.onload = build_something();
}
qriousScript.src = 'qrious.min.js';
qriousScript.type = 'text/javascript';
head.appendChild(qriousScript);
}
});

@Luigius
Copy link
Author

Luigius commented Aug 21, 2021

Hi,
I solved the problem redownloading the qrious.js from github (link from the doc page https://cdnjs.cloudflare.com/ajax/libs/qrious/4.0.2/qrious.js).

Now without changing a line works, but until the chrome update was working fine. Not sure what was the problem
Thanks
Luigi

@ROBERT-MCDOWELL
Copy link

better you use the code above, it's not good to create an aboject before the page is loaded anyhow.
chrome often changes preloading instructiona that can do things faster or in different order. your issue obviuosly comes from the fact that the object is created before the element is created, even if it's loaded after.
loading the js script file once loaded (for this case) is 100% sure that it will react the same for all browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants