Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need a url joining helper function (the one below is modified from <a href="https://stackoverflow.com/questions/7649423/python-urljoin-equivalent-in-as3/7699080#7699080">another answer</a> I gave). Complete code, assuming you add <code>class="httpsLink"</code> to the special <code>&lt;a&gt;</code> links:</p> <pre><code>var urlJoin = function(base, relative) { // See if there is already a protocol on this if (relative.indexOf("://") != -1) return relative; // See if this is protocol-relative if (relative.indexOf("//") == 0) { var protocolIndex = base.indexOf("://"); return base.substr(0, protocolIndex+1) + relative; } // We need to split the domain and the path for the remaining options var protocolIndexEnd = base.indexOf("://") + 3; if (base.indexOf("/", protocolIndexEnd) == -1) // append slash if passed only http://bla.com base += "/"; var endDomainIndex = base.indexOf("/", protocolIndexEnd); var domain = base.substr(0, endDomainIndex); var path = base.substr(endDomainIndex); if (path.lastIndexOf("/") != path.length-1) // trim off any ending file name path = path.substr(0, path.lastIndexOf("/")+1); // See if this is site-absolute if (relative.indexOf("/") == 0) { return domain + relative; } // See if this is document-relative with ../ while (relative.indexOf("../") == 0) { relative = relative.substr(3); if (path.length &gt; 1) { var secondToLastSlashIndex = path.substr(0, path.length-1).lastIndexOf("/"); path = path.substr(0, secondToLastSlashIndex+1); } } // Finally, slap on whatever ending is left return domain + path + relative; }; $('a.httpsLink').click(function(e){ e.preventDefault(); location.href = urlJoin(location.href, $(this).attr('href')).split('http://').join('https://'); }); </code></pre> <p>This will work with any type of links, be they absolute or relative.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload