在新窗口中打开页面上的div,同时保持通过WebSockets的更新它的能力 [英] Open a div on the page in a new window while maintaining the ability to update it via websockets
本文介绍了在新窗口中打开页面上的div,同时保持通过WebSockets的更新它的能力的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在页面在新窗口中打开(新的浏览器窗口),同时保持获得的WebSocket更新,以便通知可以在两个窗口接收能力的部分(在那里我有通知)当事情被更新
I am trying to have a section of the page (where i have notifications) open in a new window (new browser window) while maintaining the ability to get websocket updates so the notifications can be received on both windows when something gets updated.
我想知道是否有无论如何要做到这一点使用jQuery或任何其他方法。我使用的框架是骨干如果该事项。
I am wondering if there is anyway to do this using jQuery or any other method. The framework I am using is backbone if that matters.
在此先感谢您的任何想法!
Thanks in advance for any ideas!
推荐答案
尝试
HTML
<textarea placeholder="click `open popup`
to open and update"></textarea>
<br />
<input type="button" value="open">
<input type="button" value="close">
JS
$(function () {
$("input[value=open]").focus().one("click", function () {
$("body").append("<br /><span class=update></span>");
var popup = window.open("", "popup", "width=200, height=100");
popup.document.write("popup ready");
$(".update").html("popup ready");
popup.focus();
$("textarea").on("change", function (e) {
popup.document.write($(this).val() + "<br />");
$(".update").html(function (i, o) {
return o + $(e.target).val() + "<br />";
});
$(this).val("");
return popup.focus();
}).change();
$("input[value=close]").on("click", function () {
popup.close();
return $("textarea").attr("placeholder", "popup closed");
});
return $("textarea").attr("placeholder", "popup ready to update");
});
});
http://jsfiddle.net/guest271314/b2e7t/
这篇关于在新窗口中打开页面上的div,同时保持通过WebSockets的更新它的能力的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文