0

我的问题是。如何在屏幕底部显示弹出窗口(不在浏览器窗口底部)?

我应该使用哪个属性?

4

2 回答 2

2

屏幕的属性在其中window.screen,其中包含用于availHeightavailWidth其他的数据。

https://developer.mozilla.org/en-US/docs/DOM/window.screen

作为如何使用这些在屏幕右下方打开弹出窗口的示例:http: //jsfiddle.net/steveukx/56XG6/

于 2013-01-10T08:16:09.950 回答
1

###Webkit-通知?如果您正在寻找 Webkit 通知,那么请使用以下内容:

<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <title>Desktop Notifications</title>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript">
            function checkNotifications() {
                if (window.webkitNotifications)
                    alert("Notifications are supported!");
                else
                    alert("Notifications are not supported for this Browser/OS version yet.");
            }
            function createNotificationInstance(options) {
                if (window.webkitNotifications.checkPermission() == 0) { // 0 is PERMISSION_ALLOWED
                    if (options.notificationType == 'simple') {
                        return window.webkitNotifications.createNotification('icon.png', 'Notification Title', 'Notification content...');
                    } else if (options.notificationType == 'html') {
                        return window.webkitNotifications.createHTMLNotification('http://localhost/');
                    }
                } else {
                    window.webkitNotifications.requestPermission();
                }
            }
        </script>
        <style type="text/css">
            * {font-family: Verdana, sans-serif;}
            body {font-size: 10pt; margin: 0; padding: 0;}
            p {margin: 5px;}
            a {color: #09f; text-decoration: none;}
            a:hover {color: #f00;}
        </style>
    </head>
    <body>
        <p><strong>Desktop Notifications</strong></p>
        <p>Lets see how the notifications work in this browser.</p>
        <p>
            <a href="#" onclick="checkNotifications(); return false;">Check Notification Support</a>.
            Next <a href="#" onclick="alert('Notifications are ' + ((window.webkitNotifications.checkPermission() == 0) ? '' : 'not ') + 'allowed!'); return false;">Check Notification Permissions</a>
            and if permissions are not there,
            <a href="#" onclick="window.webkitNotifications.requestPermission(); return false;">Request Permissions</a>.
            Create a
            <a href="#" id="text">Simple Notification</a>
            or
            <a href="#" id="html">HTML Notification</a>.
        </p>
    </body>
    <script type="text/javascript">
        document.querySelector("#html").addEventListener('click', function() {
            if (window.webkitNotifications.checkPermission() == 0) {
                createNotificationInstance({ notificationType: 'html' });
            } else {
                window.webkitNotifications.requestPermission();
            }
        }, false);
        document.querySelector("#text").addEventListener('click', function() {
            if (window.webkitNotifications.checkPermission() == 0) {
                createNotificationInstance({ notificationType: 'simple' }).show();
            } else {
                window.webkitNotifications.requestPermission();
            }
        }, false);
    </script>
</html>

###截屏


(来源:akamai.net

注意:这仅适用于 Chrome 和其他基于 WebKit 的浏览器...有关更多信息,请参阅我可以使用 Web 通知吗?

于 2013-01-10T08:14:18.570 回答