I would like to display the image from a network camera on my web page, but the image is behind a HTTP basic authentication server.
In Firefox and Chrome I can do th
See http://support.microsoft.com/kb/834489 and http://msdn.microsoft.com/en-us/library/ie/ee330735(v=vs.85).aspx#login_creds_urls
Long story short, usernames/passwords are not formally supported under the HTTP/HTTPS protocol schemes and due to their use in phishing attacks, they were disabled in IE6 on XPSP2. Support can be manually re-enabled by the user using a registry override (FEATURE_HTTP_USERNAME_PASSWORD_DISABLE
) but this is not recommended.
Best way is to create a login page, then setup port forwarding on your router to display the camera. Does the camera come with web software?
You can load your img
with AJAX, using XMLHttpRequest. As you might know, XMLHttpRequest has a setRequestHeaders
method, so you will be able to manipulate headers for your request, hence, you will be able to do basic HTTP authentication.
Bottom line: Not all browsers allow this. It may work in some but not others.
But as someone else has said already, it's not very safe -- you're effectively giving the login and password details to anyone who browses the page. Not good.
A better option would be proxy it through the same server that you're providing the html code from, then the href in the <img>
tag could just be a local URL, and no-one need know where the image is actually coming from.