Martynas Grauzinis Martynas Grauzinis - 5 months ago 20
jQuery Question

Android sending sms onload JS

Hello i use this script on my landing pages, but the user needs to click a button for it to work.

<a onclick="ClickTrack('click5')" href="smsto:NR?body=TEXT" class="btn_2" >
<strong><span class="cta-clik">Click to send sms</span></strong>
</a>


Does anybody know how to make it work without button click but when website Loads?

Answer

For the redirect part, you can make a function like this:

function redirect()
{
    window.location.href = "smsto:NR?body=TEXT"
}

If you use JQuery, you could use document.ready inside your script file:

$('document').ready(funtion(){
  redirect();
});

If you don't, include the script in the bottom of your page like this:

<body>
    <!-- content here -->

    <script>
    document.addEventListener("DOMContentLoaded", function(event) { 
        redirect();
    });
    </script>  
</body>
Comments