--- title: Notification.dir slug: Web/API/notification/dir translation_of: Web/API/Notification/dir ---
{{APIRef("Web Notifications")}}
{{domxref("Notification")}} 的`dir`是一个只读属性,它表示Notification中显示的文本方向 会{{domxref("Notification.Notification","Notification()")}} 构造函数里制定的`dir` 属性的值来设定。
{{AvailableInWorkers}}
var direction = Notification.dir;
一个表示文本方向的{{domxref("DOMString")}}变量。 可能的取值为:
auto
: 继承浏览器的语言设置里制定的方向 (默认)ltr
: 从左到右rtl
: 从右到左提示:似乎大多数浏览器都忽略了明确的LTR 和RTL 设置,要按照与浏览器的通用设置来操作。
The following snippet fires a notification; a simple options
object is created, then the notification is fired using the Notification()
constructor.
var options = { body: '你去过新疆吗?', dir: 'rtl' } var n = new Notification('测试通知',options); n.dir // 应该返回 'rtl'
规则 | 状态 | 注释 |
---|---|---|
{{SpecName('Web Notifications','#dom-notification-dir','dir')}} | {{Spec2('Web Notifications')}} | Living standard |