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

送分小仙女□ 提交于 2019-12-02 06:42:13

问题


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?


回答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.



来源:https://stackoverflow.com/questions/13462925/how-to-test-if-an-employee-is-connected-via-vpn-with-client-side-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!