使用HTML5通知激活浏览器选项卡

时间:2015-08-31 10:28:17

标签: html5 browser notifications web-notifications

我正在使用HTML5 Notification API在新内容可用时显示消息。我想显示浏览器选项卡,该选项卡会在用户单击邮件时激活通知,但我无法找到API来执行此操作。我确实找到了Page Visibility API,但它似乎只在标签更改时发送事件,而不允许我激活标签。

是否可以像这样控制浏览器,还是根本不允许?

1 个答案:

答案 0 :(得分:7)

如果有的话, <script type="text/javascript" src="../Scripts/OpenLayers.js" ></script> <script type="text/javascript" src="../Scripts/expand.js"></script> <!-- map built with OpenLayers api on OpenStreetMap --> <script type="text/javascript"> map = new OpenLayers.Map("mapdiv"); map.addLayer(new OpenLayers.Layer.OSM()); epsg4326 = new OpenLayers.Projection("EPSG:4326"); // WGS 1984 projection projectTo = map.getProjectionObject(); // The map projection (Spherical Mercator) // Define center-point var lonLat = new OpenLayers.LonLat(8.2891666666666666666666666, 46.8344444444444444444).transform(epsg4326, projectTo); map.setCenter(lonLat, 8); </script> 应该在通知的window.focus()事件处理程序中执行此操作。

有关详细信息,请参阅https://notifications.spec.whatwg.org/#activating-a-notification