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

1

1

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?

Anastos answered 19/11, 2012 at 21:52 Comment(0)
S
1

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

$(function(){
    $('#test').show();
});

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

Shrovetide answered 19/11, 2012 at 21:58 Comment(1)
@brOlite- Updated with a test case that works fine in Chrome/FF/IE(7-9 emulated).Shrovetide

© 2022 - 2024 — McMap. All rights reserved.