0

该应用程序在导航栏中有一个 Home 项(该项在所有页面中)。我希望当单击主页项目时,根据页码向用户显示一个警告框,警告他们,所有未保存的工作都将丢失。如果用户按下是,他或她将被带到应用程序主页并且不会保存任何内容。如果他们按否,他或她将留在页面上。

目前,此对话框显示在每个页面中。在 Oracle Application Express 中shared components > navigation bar > target area,这些是我的设置:

目标类型 =url

网址目标 =

javascript:if(confirm('All unsaved work will be lost?')) 
{window.location.href ='f?p=&APP_ID.:1:&SESSION.:&APP_PAGE_ID.';}

我希望这种行为只发生在选定数量的页面中。当用户单击未包含在此列表中的页面时,不应显示警告框,并将用户带到应用程序主页。

4

1 回答 1

1

What you'd want is a dynamic action which targets the navigation bar entries. However, there is simply no easy way to selectively enable or disable this action on select items save for testing the text of the anchor tag. That would mean you'd be hardcoding values in your dynamic action to test the links, which i will not recommend. There are no classes that can be assigned, and no onclick events.
You could use the code you posted, and have a javascript function which takes a page id as input parameter and then checks the page id against a list of pages which allow the action, but again complicated. It could be made dynamic with some ajax, but since you're unfamiliar with javascript it's better to first get accustomed with it before tackling that.
So, instead of inventing something like this, take a look at this save before exit plugin. It will check for unsaved changes, and you can add this just to the pages you want it on.

于 2012-09-03T07:50:37.823 回答