Problem with pricing TABS breaking on page using HTTPS

1 reply · opened Aug 3, 2016

MmyhostirlAug 3, 2016

Hi

Sorry for the double post but I think my last topic is marked resolved and is not appearing anymore ?

Original Query

We recently integrated Canvas HTML theme into our WHMCS 6.3 install and everything appeared to be working fine until we added a smarty function required for WHMCS to define the base url

{if $systemurl}{/if}

Now when I attempt to load a page using shortcodes like pricing boxes using a tabular setup , it seems that the page tries to load inside each tab


- [Monthly](#tabs-1)

- [1 Year](#tabs-2)

- [2 Year](#tabs-3)

Also every ahref referencing a ‘#’ just brings the user back to the base URL which didnt happen before.

Some something somewhere is breaking the canvas theme and I think it lies within the functions.js file

Has anyone come accross this before ?

In browser console the error is

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.

So @spidometrs replied with the follow fix which seems to have worked

Open file footer.tpl, and after

<script type=”text/javascript” src=”{$WEB_ROOT}/templates/{$template}/js/plugins.js”></script>

add

<script type=”text/javascript”>
$.fn.__tabs = $.fn.tabs;
$.fn.tabs = function (a, b, c, d, e, f) {
var base = location.href.replace(/#.*$/, ”);
$(‘ul>li>a[href^=”#”]’, this).each(function () {
var href = $(this).attr(‘href’);
$(this).attr(‘href’, base + href);
});
$(this).__tabs(a, b, c, d, e, f);
};
</script>

Further, in each link of the tab, add {$smarty.server.REQUEST_URI}
For example:
<_li><a href=”{$smarty.server.REQUEST_URI}#tabs-1″> Bla-bla1</li>
<_li><a href=”{$smarty.server.REQUEST_URI}#tabs-2″> Bla-bla2</li>
<_li><a href=”{$smarty.server.REQUEST_URI}#tabs-3″> Bla-bla3</li>

Enjoy!

#######################################################

But a few days ago I spotted if the page request is using HTTP the tabs are broken again.

If the page contains the tabs and the request is HTTPS the page breaks and the following error is in the console

XMLHttpRequest cannot load https://www.mydomain.com/page-name/. Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://www.mydomain.com’ is therefore not allowed access.

Do I need to modify the code provided from @spidometrs

Thanks
Martin

SSemicolon WebSTAFFAug 8, 2016

Hello,

This is a CORS Issue: https://en.wikipedia.org/wiki/Cross-origin_resource_sharing and unfortunately this will not work as the requested resource is from an HTTPs URL which will not allow any access to an iFrame or via AJAX. Only HTTP URLs will work fine.

Hope this Helps.

Let us know if we can help you with anything else or if you find any further issues.

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard