Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7992509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:35:00+00:00 2026-06-04T13:35:00+00:00

Displaying an image from a remote server: <img src=http://remotehost/path/to/a.png alt=Image A /> However, if

  • 0

Displaying an image from a remote server:

<img src="http://remotehost/path/to/a.png" alt="Image A" />

However, if the current page is accessed via HTTPS, linking images via unencrypted HTTP will yield security warnings. While I could just specify https:// regardless of the current protocol, doing so would be wasteful since I really don’t care to secure the transmission of this image unless it is necessary (when the visitor is using HTTPS).

Is it possible to specify a URL for the src attribute of the img tag such that the protocol in the URL is dynamically chosen based on the protocol used to access the current page? To illustrate what I mean:

<img src="(JavaScript's window.location.protocol)//remotehost/path/to/a.png" alt="Image A" />

What if we use JavaScript? We could give the img tag an id so that we can locate it and set the src to start with window.location.protocol.

Could also use base64 to bypass the HTTP/HTTPS problem altogether, but this isn’t ideal for what I’m doing.

What can you guys recommend?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T13:35:01+00:00Added an answer on June 4, 2026 at 1:35 pm

    Just do :

    <img src="//remotehost/path/to/a.png" alt="Image A" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My app has to load an image from a http server and displaying it
I'm displaying images from outside my web root, like this: header('Content-type:image/png'); readfile($fullpath); The content-type:
I'm displaying an image like this: <img src='counter.asp'> counter.asp is doing a hit-counter do
friends, i have a page on which i am displaying image from gallery then
I am having trouble displaying an image from the internet on my html page.
I am retrieving an image from SQL Server to display on a new page
I'm having trouble with displaying image from db. I think that method for saving
When i am displaying image from folder using Handler.ashx ans then try to save
I have a variety of image sets that I'm displaying on a web page
I am displaying image's from web using Image downloading logic from url, I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.