Putting a protocol in the url is not necessary

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Putting a protocol in the url is not necessary

Post by Luke »

So, I was in a predicament recently where I needed to request a secure url if I was on a secure page and a non-secure url otherwise. Unfortunately, this was on a remote server so I needed to use a protocol, or so I thought (I couldn't just do something like this/that/myfile.js). So, I tried just not putting a protocal, and voila! It just used whatever protocol the current page was using. This is very cool, but I just want to make sure there is no downside to this. Anything anybody knows of that is wrong with doing this?

Code: Select all

<script type="text/javascript" src="//www.example.com/scripts/some-script.js"></script>
miro_igov
Forum Contributor
Posts: 485
Joined: Fri Mar 31, 2006 5:06 am
Location: Bulgaria

Post by miro_igov »

Wow cool, i was doing PHP test for SSL when i need to use external includes.

Does this work on all browsers?
Post Reply