如何测试员工是否通过VPN与客户端JavaScript连接

如何测试员工是否通过VPN与客户端JavaScript连接

问题描述:

有员工会访问外部网站,以查看内部托管网站的链接。我们只希望链接显示如果他们有VPN入网络。

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.

如何使用JavaScript,我可以测试不在线外部。

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

我试图使用.JS文件,但它可以获得缓存,似乎可用,当它真的不是。

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.

也许JSONP与MockJax避免跨站点脚本错误?

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

在内部网站上创建一个JS文件,嵌入链接或将它们从 display:none 更改为(或任何显示)。在页面本身只是创建一个对脚本的引用,并附加当前日期时间到结束,以避免从服务器缓存。

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.

测试用例(这假设你有localhost设置,但您可以将其更改为任何Intranet位置):
前往此处和将不显示文本。
localhost 下设置内容为

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();
});

刷新页面,它将显示DIV的内容。

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