0

Possible Duplicate:
Can I change all my links to just //?

Is it possible to use just :// on all links during my development? For example, I would like to output

<select><option value="://my-page.html">Goto Page</option></select>

not

<select><option value="http://my-page.html">Goto Page</option></select>

or

<select><option value="https://my-page.html">Goto Page</option></select>

I have seen this somewhere before and was wondering if it is ok to do this as it would save a lot of time during development.

Also depending on what protocol the user comes in on, they would then be able to stay on that protocol throughout my website.

Community
  • 1
  • 1
Ian Wilkinson
  • 141
  • 1
  • 1
  • 13

1 Answers1

0

I am not sure why you are using <option value as your example. In this case, the browser will not recognize this as URL, so you would have to add the protocol (http/https) manually where you're using these values. <option value is just a text string from browser's point of view.

But you can achieve what you want for values the browser knows are URLs. For example:

<img src="/images/1.jpg" />
<script src="/js/jquery.js" />

By putting / in the beginning of the path, you tell the browser that the path is absolute, meaning that it starts from the root of your site.

Dmytro Shevchenko
  • 33,431
  • 6
  • 51
  • 67
  • Thanks Shedal, my mistake, it was meant to be , not just on selects but on all img's too – Ian Wilkinson Apr 18 '12 at 02:55
  • @Ian Is your intent to use these values in javascript? Like setting `document.location` to a path like this? – Dmytro Shevchenko Apr 18 '12 at 02:57
  • I have an issue with my https, its new ssl cert and if i navigate to my website using https i get warnings in ie saying that not all content is secure so i was hoping to just use :// to save me rewriting alot of my system and accomodating https:// within my scripts. – Ian Wilkinson Apr 18 '12 at 03:03