Skip to: Site menu | Main content

Email Facebook LinkedIn Twitter Google

Blog...

http vs. https links.

Thanks to Tim Jackson for bringing this one to my attention. Since I've worked in Coldfusion I've always used code similar to this:


<cfset variables.protocol = iif(CGI.SERVER_PORT EQ 443, de("https"), de("http"))>

So that I could avoid the "This page contains unsecure items." message when embedding Flash, Javascript, images, etc.


<img src="#variables.protocol#://www.foo.com/linkedimage.jpg"/>

Tim advised me that he had found a new way to avoid this without using server-side code:


<img src="//www.foo.com/linkedimages.jpg"/>

Apparently the browser retains the current protocol. I've tested this in IE7 and Firefox using images, Flash, anchors, and javascript.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001.