我有一个适用于除 Brave Browser 之外的所有浏览器的功能。知道为什么吗?
有一个表单调用一个函数来重定向到用户输入的新 URL。在勇敢的浏览器中调用时,它什么也没做。它适用于所有其他浏览器。这是从 Wordpress 网站调用的。这和它有什么关系吗?
<form id="url-10">
<input id="red-border-error-2" class="url10-form" type="text" name="urlName-10">
<input class="url10-button" type="submit" value="Build your app"></input>
</form>
<div id="error-message-10"></div>
<script>
// JavaScript goes here
document.getElementById("url-10").addEventListener("submit", (event) => {
event.preventDefault()
let errorMessage = document.getElementById("red-border-error-2").placeholder = " Type your store URL here ";
let x = document.getElementById("red-border-error-2");
let myForm = document.getElementById("url-10");
let formData = new FormData(myForm);
if (formData.get("urlName-10") === "") {
return x.classList.add('placeholder-red-text');
errorMessage;
}
else{
EndOfUrl = sanitizeDomainInput(formData.get("urlName-10"));
newUrl = redirectLink(EndOfUrl);
markConversionAndRedirect(newUrl);
return false;
}
});
function markConversionAndRedirect(newUrl) {
gtag('event', 'conversion', {
'send_to': 'G-Q0HF9N3DYR/connect_square',
'event_callback': function () { window.location.href = newUrl }
})
};
function sanitizeDomainInput(input) {
input = input || 'unknown.com'
if (input.startsWith('http://')) {
input = input.substr(7)
}
if (input.startsWith('https://')) {
input = input.substr(8)
}
var regexp = new RegExp(/^(([a-zA-Z]{1})|([a-zA-Z]{1}[a-zA-Z]{1})|([a-zA-Z]{1}[0-9]{1})|([0-9]{1}[a-zA-Z]{1})|([a-zA-Z0-9][a-zA-Z0-9-_]{1,61}[a-zA-Z0-9]))\.([a-zA-Z]{2,6}|[a-zA-Z0-9-]{2,30}\.[a-zA-Z]{2,3})$/)
return regexp.test(input) ? input : 'unknown.com';
};
function redirectLink(domain) {
const urlParams = new URLSearchParams(window.location.search);
const refValue = urlParams.get('ref');
return `https://dashboard.getorda.com/signup/?state=${domain}` + (refValue ? `_${ refValue }` : '');
};
</script>