Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

javascript - How to handle 'Are you sure?' popup in Electron

I am creating a bot in Electron.js that posts to a website. When it makes a selection, the page navigates and submits a form. I'm pretty sure it's firing a beforeunload event and asking the user for confirmation. When I tried to set

window.onbeforeunload = ()=>{}

it didn't throw an error but it still continued to ask if I was sure.

snippet of the page html,

<form id="repoststore" method="post" action="https://some-navigation.com">
<select style="width: 100%; display: none;" name="sid" id="sid" onchange="setConfirmStore()">
<option value="-1">-- Repost store item --</option>
...
</form>

Could this confirm dialog box be caused by the 'setConfirmStore()' function that appears to trigger onchange? If so, is there a way I can prevent this?

I am using electron for the application and Puppeteer for the automation.

Thank you for your time and expertise!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...