简体   繁体   中英

Set Username and Password for Website with JS

I am trying to embed a camera (DCS-5605) on a plain html site. I´ve managed to embed it, but there are buttons I need to send commands to the camera. I am able to send the commands, but the camera always asks me for a login. I wish to bypass this or programmatically set the values.

How can I do this?

The username and password are prompted by the regular IE login pop up.

way back in the day I used to be able to do it as follows: http://username:password@website.com but after IE6 that is no longer possible.

How can I go about this? I´m trying to keep it as an HTML site with regular JS.

Thank you!

SlickD,

You're looking for the Authorization HTTP header. It looks like the DCS-5605 just uses basic authentication, which is indeed disabled in some web browsers (because of url spoofing concerns and such). You can get around this by manually crafting the HTTP request being sent to the camera and appending the Authorization header -- which looks like...

Authorization: Basic username:password

Where username:password is a base 64 encoded string.

This might be challenging for you, though. I'm guessing you're embedding with an iframe, and obviously you can't modify the request in an iframe. So you'd have to proxy that request or somesuch. Depending on what resources are protected, you might be able to get away with using the XHR to embed the Authorization header and just loading the resulting html. You'll probably have some scripting issues with that though. Server side solutions may be the best way to go here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM