2

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?

Randy
  • 8,380
  • 4
  • 35
  • 53

2 Answers2

1

Personally I dislike the inline bindings but you could try putting it on your body tag

<body onload="ClickTrack('click5')">

If possible bind in your logic or just call it like @randy was saying.

Taplar
  • 24,246
  • 4
  • 18
  • 33
0

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>
Randy
  • 8,380
  • 4
  • 35
  • 53
  • This is not my js code onclick="ClickTrack('click5'). this line was added by someone to track click. I jut need to run this part: href="smsto:NR?body=TEXT" class="btn_2" > Click to send sms – Martynas Grauzinis Jun 30 '16 at 12:57