Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 23318
  • Total topics 4048
  • Total members 5574
  • Our newest member
    ALF5583

TOP POSTERS

Handling jquery calls over https

All problems related to JavaScript and AJAX are discussed and resolved here.
   

Handling jquery calls over https

Postby jonesevan007 » Mon Sep 28, 2009 8:20 pm

Hey guys,

As recommended I'm calling google for my jQuery javascript:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

The only trouble is that it's an insecure http call on my https pages. Is there a way to switch between http and https based on what page the visitor is on? I'm currently doing the inelegant solution of just hardcoding https:// for the call.

Thanks for the advice,
- Evan
User avatar
jonesevan007
Smashing <table>
 
Posts: 22
Joined: Sun Feb 15, 2009 4:17 pm
   

   

Re: Handling jquery calls over https

Postby markdavison » Tue Oct 27, 2009 12:44 pm

Hi,

Why not do what google do in the click tracking code thye provide? Not tested it but off the top of my head something like this shoud do it:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://" : "http://");
document.write(unescape("%3Cscript src='" + gaJsHost + "ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js' type='text/javascript'%3E%3C/script%3E"));
</script>
markdavison
 
Posts: 7
Joined: Tue Oct 20, 2009 12:59 pm
   


Return to JavaScript & AJAX



Who is online

Users browsing this forum: No registered users and 1 guest

cron