在 android 中扫描二维码后停止对 phone 的 instascan 提醒
Stop instascan alert to phone after QR code scan in android
我有一个使用 instascan 扫描 QR 码的应用程序,但每次扫描 android phone 上的 QR 码时,都会弹出一条带有解码结果的警报。例如,如果我生成一个带有文本“我喜欢香蕉”的 QR 码,那么警报会显示“https://mywebsite.com says I like bananas”。
有什么方法可以阻止显示此警报?它不会发生在我的笔记本电脑或平板电脑上,只有我的 phone。如果您想查看,这是我的代码:
<video id="preview" visible="true"></video>
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
//When a QR code is detected
scanner.addListener('scan', function (content) {
//If it is a url
if (content.match(/^http?:\/\//i)) {
//Redirect to new page
window.open(content);
} else {
var options = {};
options.url = "CameraList.aspx/GetContent";
options.type = "POST";
options.data = JSON.stringify({ content });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (result) { };
options.error = function (err) { };
$.ajax(options);
}
});
</script>
感谢任何帮助。
我根据这个post想出来了:Stop alert javascript popup in webbrowser c# control
我想 return 来自名为 GetContent 的方法的字符串,并仅在该字符串不为空时才向用户发出警告:
//write a new function for alert that expects a boolean value
var fnAlert = alert;
alert = function (message, doshow) {
//only if you pass true show the alert
if (doshow === true) {
fnAlert(message);
}
}
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
//When a QR code is detected
scanner.addListener('scan', function (content) {
//If it is a url
if (content.match(/^http?:\/\//i)) {
//Redirect to new page
window.open(content);
} else {
var options = {};
options.url = "CameraList.aspx/GetContent";
options.type = "POST";
options.data = JSON.stringify({ content });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (result) {
//If my c# method GetContent returns a value
if (result != "") {
//then alert the user by passing true
alert(result, true);
}
};
options.error = function (err) { };
$.ajax(options);
}
});
我有一个使用 instascan 扫描 QR 码的应用程序,但每次扫描 android phone 上的 QR 码时,都会弹出一条带有解码结果的警报。例如,如果我生成一个带有文本“我喜欢香蕉”的 QR 码,那么警报会显示“https://mywebsite.com says I like bananas”。
有什么方法可以阻止显示此警报?它不会发生在我的笔记本电脑或平板电脑上,只有我的 phone。如果您想查看,这是我的代码:
<video id="preview" visible="true"></video>
<script type="text/javascript">
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
//When a QR code is detected
scanner.addListener('scan', function (content) {
//If it is a url
if (content.match(/^http?:\/\//i)) {
//Redirect to new page
window.open(content);
} else {
var options = {};
options.url = "CameraList.aspx/GetContent";
options.type = "POST";
options.data = JSON.stringify({ content });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (result) { };
options.error = function (err) { };
$.ajax(options);
}
});
</script>
感谢任何帮助。
我根据这个post想出来了:Stop alert javascript popup in webbrowser c# control
我想 return 来自名为 GetContent 的方法的字符串,并仅在该字符串不为空时才向用户发出警告:
//write a new function for alert that expects a boolean value
var fnAlert = alert;
alert = function (message, doshow) {
//only if you pass true show the alert
if (doshow === true) {
fnAlert(message);
}
}
let scanner = new Instascan.Scanner({ video: document.getElementById('preview') });
//When a QR code is detected
scanner.addListener('scan', function (content) {
//If it is a url
if (content.match(/^http?:\/\//i)) {
//Redirect to new page
window.open(content);
} else {
var options = {};
options.url = "CameraList.aspx/GetContent";
options.type = "POST";
options.data = JSON.stringify({ content });
options.dataType = "json";
options.contentType = "application/json";
options.success = function (result) {
//If my c# method GetContent returns a value
if (result != "") {
//then alert the user by passing true
alert(result, true);
}
};
options.error = function (err) { };
$.ajax(options);
}
});