0

I use the following syntax in my application so that images are loaded over https or http depending upon how the page was loaded.

<img src="//path_to_image.jpg">

This works fine in Chrome but firefox does not display any images.

What can I do to fix this ?

isherwood
  • 58,414
  • 16
  • 114
  • 157
runtimeZero
  • 26,466
  • 27
  • 73
  • 126
  • basic debugging: check your server's access log to see what each browser's requesting (if anything). – Marc B Nov 18 '15 at 20:17

2 Answers2

2

The // use to support multiple protocol (i.e. http or https), these type of URL is known as "protocol relative URLs" and use with complete domain name. Mostly CDN url are used with //.

If you are planning to use // make sure you use full domain url (i.e. //xyz.com/images/path_to_image.jpg). If you just want to use relative path from the root then use single slash (i.e. /)

Following like help you to understand // usage

Two forward slashes in a url/src/href attribute

Community
  • 1
  • 1
Avinash Jain
  • 7,200
  • 2
  • 26
  • 40
1

Using // will only work with a full URL ('//yourhost.tld/directory/path_to_image.jpg'). In your case one slash /, should be enough!

svrnm
  • 1,036
  • 6
  • 17