Automatic selection : http or https javascript inclusion

Is it possible to automatically detect whether or not the page is accessed via http or https and then include a https://url.js or http://url.js ?

Is javascript included via https any different? I'm talking about cache age and so on?

Thanks, Wesley

Answers


Use a protocol-relative link, starting with // instead of http or https:

<script type='text/javascript' src="//path/to/file.js"></script>

Need Your Help

Querying a 'column' in core data

cocoa core-data

I have a core data entity named "Folder". Each "Folder" has a 1-to-many relationship with the entity "File", and each file contains the field "filename".

2D Dynamic Array Allocation and Passing by Reference in C

c multidimensional-array segmentation-fault pass-by-reference dynamic-memory-allocation

Can someone wiser than I please explain to me why the following code segment faults? There is no problem allocating the memory by reference, but as soon as I try to assign anything or free by refe...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.