如何在其他计算机上远程刷新网页 [英] How to refresh a webpage remotely on other computers
问题描述
假设我有PC 1和PC 2.PC 1位于挪威,PC 2位于美国.当前在PC 2的Web浏览器中打开了www.webpage.com.
Lets say I have PC 1 and PC 2. PC 1 is located in Norway and PC 2 is located in USA. www.webpage.com is currently open on the web browser on PC 2.
现在在PC 1上,我将www.webpage.com上的背景颜色更改为红色.我将更改CSS并使用示例ftp保存它.所以问题是,如何让PC 2改变颜色而又没有人坐在计算机旁边并刷新页面.
Now on PC 1, I will change the background on the www.webpage.com color to red. I will change the css and save it using example ftp. So the question is, how can I make the PC 2 to change color without having someone to sit beside the computer and refresh the page.
如何远程告诉服务器刷新网站?
How can I remotely tell the server to refresh the website?
推荐答案
要进行草绘,我将在初始页面加载时将php的"pageversion"编码为javascript:
To sketch out I would encode a 'pageversion' from php into the javascript on the initial page load:
var pageversion=<?php echo $pageversion ?>;
然后使用EventSource
Then use EventSource
eventer = new EventSource("/eventeg.php");
eventer.onmessage = function (event) {
var datasent=event.data;
//use data to compare versions and then reload
};
服务器通过保持活动连接发送数据的地方-只需让服务器实时更新其发送的版本,如果不相等,则执行您需要的操作-例如,警告用户,然后在超时后强制刷新.然后,重新加载将对齐版本.您可能要使用http-refresh以及javascript失败的备份.
Where the server sends data through a keep-alive connection - simply have the server update the version it sends in realtime and if un-equal do what you need - eg warn the user then have it force refresh after a timeout. The reload will then align the versions. You might want to use http-refresh as well as a backup for javascript failure.
这篇关于如何在其他计算机上远程刷新网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!