Optimalworks Ltd web design, SEO, training and consultancy 

the site completely surpassed my expectations GT, AutoDirector, we build websites that work, my website is great - I love it MP, XL Autos, reach more customers, make more sales, it's more than I ever could have expected LM, Trade Cars UK, we can help your business grow, 99% of business now comes from my website GV, Bash Events, promoting standards throughout the web industry, your contribution added a level of quality we would otherwise have struggled to achieve PS, Hemsley Fraser
  1. home
  2. Services
  3. Portfolio
  4. Contact us
  5. blog

HTTP, HTTPS, and shared resources

written by Craig, 19 October 2007

If you’re building secure HTTPS web pages, you need to be careful not to reference HTTP resources. If you share resources across HTTP and HTTPS pages, it’s not a big problem because you just use relative and absolute URLs, e.g. /shared/mypic.jpg ../../shared/script/myscript.js

But what if you need to use resources on another web server (a real problem for mashups and remote scripting)? You cannot use this code as it will throw a security message: <img src="http://example.com/image.jpg" />

The answer is to leave the protocol off the URL, i.e. <img src="//example.com/image.jpg" />

So simple, yet I’d not realised it was possible in all my years of web development. Many thanks to Ned Batchelder for the tip.

  • categories: web development
  • tags: html, ssl
  • trackback: http://www.optimalworks.net/blog/2007/web-development/https-http-urls/trackback
  • bookmark: del.icio.us, digg, facebook, reddit, Furl, Spurl, Blinklist, Slashdot, Technorati, Yahoo!
add your comments
please enter your name
please enter your email address - it will not be published anywhere
please enter your website address
please enter your comments (all are moderated and checked for spam)
  • next article: Government website accessibility guidelines 
  • previous article: The top 10 free web development editors 
search
  • all popular (5)
  • courses (1)
  • general (3)
  • hardware (1)
  • software (24)
    • free download (6)
    • web browsers (9)
    • web servers (2)
  • web development (31)
    • accessibility (4)
    • ajax (1)
    • css (2)
    • graphic design (4)
    • html (1)
    • javascript (7)
    • php (4)
    • seo (1)

tags

  • accessibility
  • ajax
  • apache
  • award
  • computing
  • css
  • design
  • developers
  • dom
  • download
  • editor
  • firefox
  • funny
  • graphics
  • hardware
  • html
  • ie
  • javascript
  • opera
  • php
  • portfolio
  • review
  • safari
  • seo
  • server
  • software
  • ssl
  • standards
  • wordpress
  • xml
  1. site map
  2. home
  3. Services
  4. Portfolio
  5. Contact us
  6. blog
  7. RSS feed
  8. project survey

XHTML 1.0 | CSS 2.1 | WAI AAA | printer-friendly

©2008 Optimalworks Ltd, Devon, UK. Registered in England and Wales No. 5922205.

This page can be viewed at http://www.optimalworks.net/blog/2007/web-development/https-http-urls