This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Local or Remote connection availability
#1
I am trying to prepare such javascript function which would check if client can connect locally or remotely. I want use this function e.g. for changing image src from local to remote:port.

I thinked that this will be easy but there is a problem with no CORS headline.

Maybe someone has some solution?

At this moment I've prepared such solution for this task:

1. Adding 2 images with classes: '.local'(from LM local address) and '.remote'(from LM remote address)

2. Adding this function to js.
Code:
var local = $('.local > img')[0].naturalHeight > 0;
var remote = $('.remote > img')[0].naturalHeight > 0;
console.log(local, remote)
if (remote){ if(local){
alert('Local');
} else if(!local){
alert('Remote');
}
};
If someone has some better solution please shareWink
Reply
#2
If you are accessing via port forwarding then you can use window.location.host to check whether client is requesting locally or remotely.
Reply
#3
I've tried this but this tells only which shortcut user selects, no if client is lin local network or if it connects via internet. The best way will be by ping LM local address but there is some problem with using such function in js with security(cems problem (?)). The easiest working way is to add some img with local address via remote link.
Reply


Forum Jump: