How to test if an employee is connected via VPN with client-side JavaScript

There are employees that will visit the external site to see a link to an internally hosted site. We only want the link to show if they have VPN'd into the network.

How, with JavaScript, can I test the availability of something that isn't online externally.

I have attempted to use a .JS file but it can get cached and seem available when it really isn't. Same with an image.

Maybe JSONP with MockJax to avoid cross-site scripting errors?



On the intranet site make a JS file that will either embed the links or change them from display: none to display: block (or whatever display). On the page itself simply create a reference to that script and append the current date time to the end to avoid caching from the server.

Test case (this assumes you have localhost set up, but you can change it to be whatever intranet location): Go here and the text won't be displayed. Set up a file called test.js under localhost with the contents


refresh the page and it will display the DIV's contents.


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us Javascript

©2020 All rights reserved.