简体   繁体   English

跨浏览器替代 Webkit /Html 通知

[英]cross browser alternative to Webkit /Html Notification

What are cross browser alternative to Webkit /Html Notification preferably in jquery/css.什么是 Webkit /Html Notification 的跨浏览器替代品,最好在 jquery/css 中。 I basically want something that can popup from the bottom right of the page like the webkit notification我基本上想要一些可以从页面右下角弹出的东西,比如 webkit 通知

Here is a little demo that may give you some ideas...这是一个小演示,可能会给您一些想法...

Demo: http://jsfiddle.net/wdm954/XEHZw/演示: http://jsfiddle.net/wdm954/XEHZw/

Basically I'm using a fixed position div to create a small box that slides into view on the page triggered by some event (on click in this example).基本上,我使用fixed的 position div来创建一个小框,该框可以滑入由某些事件触发的页面上的视图(在此示例中单击)。

function notify(msg, delay) {
    var box = document.createElement('DIV');
    box.id = 'notification';
    // you should just style #notification in css, but w/e
    box.style.position = 'fixed';
    box.style.bottom = '10px';
    box.style.right = '10px';
    box.style.width = '200px';

    box.innerHTML = msg;
    document.body.appendChild(box);
    setTimeout(function() {
        box.parentNode.removeChild(box);
    }, delay);
}

use it like:像这样使用它:

notify('sup dude', 1000);

Edit: Jquery Version:编辑:Jquery 版本:

function notifyJquery(msg, delay) {
    $("body").append('<div id="notification" />').css({
        'display': 'none',
        'position': 'fixed',
        'bottom': '10px',
        'right': '10px'
    }).text(msg).fadeIn(400).delay(delay).fadeOut(400);
}

notifyJquery('sup dude', 1000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM