Google Chrome扩展程序:在webkit通知中使用Javascript?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了Google Chrome扩展程序:在webkit通知中使用Javascript?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1906字,纯文字阅读大概需要3分钟。
内容图文
我一直在关注Google Chrome Extensions Developer’s guide并且到目前为止能够创建一个没有弹出窗口的browser action扩展,它会触发HTML格式的webkit通知.
事实是,这个HTML文件包含动作按钮,链接和JavaScript,但它们似乎都没有响应.
这是一种设计行为,还是有办法在这些webkit通知中嵌入javascript / links / buttons?
编辑:
以下是有关该主题的一些新见解:
使用Javascript
这是一个不起作用的HTML通知页面:
<html>
<head>
<script>
alert("hey");
</script>
</head>
<body>
content
</body>
</html>
结果,通知全部为空白;不显示文本“内容”.
但是,如果我删除“警报”,则会显示文本“内容”.
我首先想到Javascript阻止了页面正确呈现,但我尝试了其他的东西:
<script>document.write("content");</script>
正确执行此javascript命令并显示文本“content”.然后我们可以假设即使在webkit桌面通知中也启用了Javascript,但是“alert”功能被禁用,并且中断了通知页面的呈现.
链接
有些链接有效,有些则没有.这是我到目前为止测试过的快速列表:
<a href="http://www.google.com/">Link</a> # => Doesn't work
<a href="http://www.google.com/" target="_top">Link</a> # => Doesn't work
<a href="http://www.google.com/" target="_parent">Link</a> # => Doesn't work
<a href="http://www.google.com/" target="_blank">Link</a> # => Works (new tab)
解决方法:
这一切都在Chromium Desktop Notifications API Specification中得到解释,其中明确表示:
If a user agent implements createHTMLNotification, it should show HTML notifications as independent browsing contexts which are equivalent in functionality to any other HTML web page, except with the following properties:
- The notification cannot be navigated. The Location attribute of the window object in the notification context should be readonly. All links should open in new, non-notification browsing contexts.
- If close() is invoked on the window object in the notification context in response to a user gesture, the user agent should proceed as if the user closed the notification, including all required event processing.
内容总结
以上是互联网集市为您收集整理的Google Chrome扩展程序:在webkit通知中使用Javascript?全部内容,希望文章能够帮你解决Google Chrome扩展程序:在webkit通知中使用Javascript?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。