0
I have a code where after an event onClick()
is triggered opens an event window.open()
where some data is sent via url to the new page, but the data is only typed in the fields, I need that after the data is entered in the field the send button is triggered too, I will send the code to exemplify.
(on the other site there is no one id
on the send button, so I’m using the class
)
let site
let valor1 = document.getElementById('v1')
let valor2 = document.getElementById('v2')
function abrirPopUp() {
site = window.open(`https://exemplo.com/send?
valor1=${valor1.value}&valor2=${valor2.value}`)
document.getElementByClassName("teste").click();
}
function fecharPopUp() {
site.close()
}
function enviarMensagem() {
abrirPopUp()
setTimeout(fecharPopUp, 13000)
}
<!DOCTYPE html>
<html>
<head>
<title>Teste automação</title>
</head>
<body>
<span>Valor 1: </span><input type="text" id="v1"><br><br>
<span>valor 2: </span><textarea id="v2"></textarea><br><br>
<button onclick="enviarMensagem()">Enviar</button>
<script type="text/javascript" src="funcoes.js"></script>
</body>
Are you trying to send from one domain to another, or to your own domain? because there is a cross-browser lock that would conflict your action when opening a new page!
– gleisin-dev
To another domain, but as such lock?
– Thiago Felipe Rosa
Modern browsers have some restrictions on not allowing certain actions to happen. This is one of them, it doesn’t work if the domain of the new window is different from the parent.
– gleisin-dev