background image
HomeRecent PostsDrupalSearchTagsRSSContactAboutAccount

Changing links to HTTPS (SSL) using jQuery

Eric.London's picture

Here's how you can change your hrefs for any node/add link to https using jQuery:

<?php
$(document).ready(function(){
  $(
'a').each(function(){
   
href = $(this).attr('href');
   
splitA = href.split('/');
    if (
splitA[1]=='node' && splitA[2]=='add') {
      $(
this).attr('href', 'https://'+location.host+href);
    }
  });
});
?>