calin-beard
11/13/2017 - 4:02 PM

Remove automatic http:// from button link

Remove automatic http:// from button link

<script>
ijQuery(document).ready(function(){ 
  var smslink = $('#element-602 a').attr('href');
  smslink = smslink.replace('http://', '');
  $('#element-602 a').attr('href', smslink);
});
</script>

// sms

<script>
  ijQuery(document).ready(function(){
    $('a[href^="http://sms:"]').each(function(){
          var js;
          js = this.href;
          js = js.replace('http://', '');
          $(this).attr('href', js);
    });
  });
</script>
<script>
  ijQuery(document).ready(function(){
    $('a[href^="http://javascript:"]').each(function(){
      // get javascript href value
      var js;
      js = this.href;
      // strip leading http:// added by editor
      js = js.replace('http://', '');
      // strip javascript:
      js = js.replace('javascript:', '');
      // strip trailing / added by editor
      if (js.substring(js.length-1) == "/") {
        js = js.substring(0, js.length-1);
      }
      // apply new value as onclick
      this.setAttribute('onclick', js);
      // replace href with no-action
      this.href = 'javascript:void(0);';
    });
  });
</script>

//should work for tel: or sms: as well
<script>
    $(document).ready(function() {
        $('a[href*="dvc://"]').each(function(i, e) {
            $(e).attr('href', function(i, att) {
                return att.match(/dvc:\/\/.*/i);
            });
        });
    });
</script>