英文:
Error in data storage system on QR code site
问题
我创建了一个项目,用于从本地存储中检索我先前为该网站生成的QR码信息。我通过浏览器扩展将这个项目集成到了网站中。
然而,我忽视了一个关键细节。代码在运行,但是网站似乎无法识别JavaScript中写的文本,而且“创建QR码”按钮似乎也不承认输入的文本,就好像从未写入一样。
我该如何解决这个问题?谢谢。
<label for="qrcodeVcardFirstname">Firstname</label>
<input type="text" id="qrcodeVcardFirstname" value="Ali"/>
<script>
var label = document.querySelector("label[for='qrcodeVcardFirstname']");
var input = document.getElementById("qrcodeVcardFirstname");
window.addEventListener("load", function() {
label.click();
var value = input.value;
value = value + " ";
input.value = value;
});
</script>
我尝试在输入文本的末尾添加了一个空格,但没有起作用。由于我是使用JavaScript添加的,系统不接受非手动添加的文本,所以“创建QR码”按钮仍然无法使用。
英文:
I have created a project to retrieve QR code information that I previously generated for this website from local storage. I integrated this project into the website using a browser extension.
However, I have overlooked a crucial detail. The code is functioning, but the website does not recognize the text written in JavaScript, and the 'Create QR Code' button does not seem to acknowledge the entered text as if it was never written.
How can I resolve this issue? Thank you.
<label for="qrcodeVcardFirstname">Firstname</label>
<input type="text" id="qrcodeVcardFirstname" value="Ali"/>
<script>
var label = document.querySelector("label[for='qrcodeVcardFirstname']");
var input = document.getElementById("qrcodeVcardFirstname");
window.addEventListener("load", function() {
label.click();
var value = input.value;
value = value + " ";
input.value = value;
});
</script>
I tried adding a space at the end of the input texts, but it didn't work. Since I added them using JavaScript, the system didn't accept the texts that were not manually added, and the 'Create QR Code' button remained inactive.
答案1
得分: 0
document.querySelector("#qrcodeVcardFirstname").value = "名字 =D";
document.querySelector("#qrcodeVcardFirstname").dispatchEvent(
new window.Event('input', { bubbles: true })
);
document.querySelector("#qrcodeVcardLastname").value = "姓氏 :)";
document.querySelector("#qrcodeVcardLastname").dispatchEvent(
new window.Event('input', { bubbles: true })
);
$("#button-create-qr-code").click();
英文:
They use Angular, angular needs aditional code to be able to trigger events with javascript. I tried this code on the console in their website and it worked:
document.querySelector("#qrcodeVcardFirstname").value = "First Name =D";
document.querySelector("#qrcodeVcardFirstname").dispatchEvent(
new window.Event('input', { bubbles: true })
);
document.querySelector("#qrcodeVcardLastname").value = "Last Name :)";
document.querySelector("#qrcodeVcardLastname").dispatchEvent(
new window.Event('input', { bubbles: true })
);
$("#button-create-qr-code").click();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论