0

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>
4

1 に答える 1

0

Brave がgtag.jsあなたが使用しているライブラリをブロックしているためだと思います。リダイレクトはgtagコールバック関数内で行われるため、Brave がこのコードを実行することはありません。

がブロックされmarkConversationAndRedirectていても機能するように関数を変更できます。gtag下記参照。

function markConversionAndRedirect(newUrl) {
  if (typeof gtag !== 'undefined') {
    // gtag is loaded, we can safely use it
    gtag('event', 'conversion', {
      'send_to': 'G-Q0HF9N3DYR/connect_square',
      'event_callback': function () { window.location.href = newUrl }
    })
  } else {
    // gtag didnt load, redirect anyway
    window.location.href = newUrl
  }
};
于 2021-10-25T03:48:45.390 に答える