【发布时间】:2021-06-13 05:30:11
【问题描述】:
我正在将 browser notifications 合并到 Oracle APEX 中,但在通知中显示自定义图标时遇到问题。通过提供图像位置的 URL,可以根据自己的喜好调整这些图标。在 Oracle APEX 中,您可以上传静态文件并使用 #WORKSPACE_IMAGES#image.png 引用它们,但是,当我在 JavaScript 中使用它时,#WORKSPACE_IMAGES# 部分不会被替换。 如何在 JavaScript 中获取静态工作区文件(png 图像)的 URL? 我已尝试将以下字符串用于通知的 URL 参数:
showNotification(
// "https://developers.google.com/web/images/web-fundamentals-icon192x192.png", // Works
// "r/xxxxx/files/static/v71/image.png", // Works, but is subject to change
// "#WORKSPACE_IMAGES#image.png", // Does not work
// "&WORKSPACE_IMAGES.image.png", // Does not work
// "#IMAGE_PREFIX#image.png", // Does not work
// "&IMAGE_PREFIX.image.png", // Does not work
notification.title,
notification.body,
() => parent.focus()
);
const showNotification = (icon, title, body, onclick) => {
// Let's check if the browser supports notifications
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
// Let's check whether notification permissions have already been granted
else if (Notification.permission === "granted") {
// If it's okay let's create a notification
let notification = new Notification(title, {
icon: icon,
body: body,
});
notification.onclick = onclick;
}
// Otherwise, we need to ask the user for permission
else if (Notification.permission !== "denied") {
Notification.requestPermission();
}
};
这些工作:
- https://developers.google.com/web/images/web-fundamentals-icon192x192.png
- r/xxxxx/files/static/v71/image.png(我使用 APEX 图像显示项正常渲染图像后的 URL)
这些不:
- #WORKSPACE_IMAGES#image.png
- &WORKSPACE_IMAGES.image.png
- #IMAGE_PREFIX#image.png
- &IMAGE_PREFIX.image.png
额外信息
- 我们在自治数据库上使用 Oracle APEX 20.2
提前致谢!
编辑: 我最终将图像上传到由托管服务提供商处理的域,因此我可以通过该 url 访问图像。
【问题讨论】:
标签: javascript oracle image url oracle-apex