数据存储系统在二维码站点上出现错误。

huangapple go评论52阅读模式
英文:

Error in data storage system on QR code site

问题

主要代码

QR码生成网站

Chrome扩展程序

我创建了一个项目,用于从本地存储中检索我先前为该网站生成的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码”按钮仍然无法使用。

英文:

MAIN CODE

QR CODE SITE

CHROME EXTENSION

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.

SCREENSHOT

&lt;label for=&quot;qrcodeVcardFirstname&quot;&gt;Firstname&lt;/label&gt;
&lt;input type=&quot;text&quot; id=&quot;qrcodeVcardFirstname&quot; value=&quot;Ali&quot;/&gt;
&lt;script&gt;

var label = document.querySelector(&quot;label[for=&#39;qrcodeVcardFirstname&#39;]&quot;);

var input = document.getElementById(&quot;qrcodeVcardFirstname&quot;);

window.addEventListener(&quot;load&quot;, function() {

  label.click();

  var value = input.value;

  value = value + &quot; &quot;;

  input.value = value;
});
&lt;/script&gt;

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(&quot;#qrcodeVcardFirstname&quot;).value = &quot;First Name =D&quot;;
document.querySelector(&quot;#qrcodeVcardFirstname&quot;).dispatchEvent(
	new window.Event(&#39;input&#39;, { bubbles: true })
);

document.querySelector(&quot;#qrcodeVcardLastname&quot;).value = &quot;Last Name :)&quot;;
document.querySelector(&quot;#qrcodeVcardLastname&quot;).dispatchEvent(
	new window.Event(&#39;input&#39;, { bubbles: true })
);

$(&quot;#button-create-qr-code&quot;).click();

huangapple
  • 本文由 发表于 2023年6月5日 01:23:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76401591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定