Bookmarklet Does Not Run

Asked 2 years ago, Updated 2 years ago, 18 views

I'm a beginner.

I'm using the js code as a bookmarklet, but I'm having trouble with the second line of clicking on the button.When I looked up the elements in the developer tool, it says name="#btnAAAA0".I'd like to investigate the cause, but what should I try?

javascript:!function(){
  document.forms['ABCD'].elements['ABCDE'].value='XX';
  document.querySelector("#btnAAAAA0").click();
}();

add
Dear Sayuri,

Thank you for your reply.
I changed the second line of JavaScript because the id and name of the element I wanted to click were as follows.

id=btnAAA0
name=btnAAA0

[After line 2 changes]

 document.querySelector("[name=btnAAA0]").click();

I tried the bookmarklet again, but it still doesn't work.

·The screen will be updated, but it is different from the behavior when the button is pressed.
- It worked just once.(It looked like I said it.)

Please let me know if there is anything else I should look into.

javascript

2022-09-29 22:33

1 Answers

 document.querySelector("#btnAAAA0").click();

As for the part,

"#btnAAAAA0" matches id="btnAAA0".
If you want to match name="#btnAAAAA0",

 document.querySelector("[name=#btnAAA0]") .click();

Shouldn't we do this?


2022-09-29 22:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.