Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top