Leaving a secure site
In certain scenarios (ex: secure sites) we want to notify the user that the link or action they have just performed will exit the current secured site/session and it is possible that data could be lost. The message allows the user to cancel or continue to the external site.
When enabled, this feature will:
- display the message to the user in the form of a modal window
- display the message your application provides
- allow your application to execute any clean up code (ex: close session, gracefully logout user etc...)
- allow your application to exclude any domains from raising the warning
Implementation
The exit script is added in the refFooter
section of the page, via the exitSecureSite
object. This object has the following properties that can be assigned a value:
exitScript
: Set to true to enable the Exit Script functionalitydisplayModal
: Set to true to show the modal dialog warning the user is about to leave the secure site.exitURL
: Set an url that you would like the user to redirect to. The user will NOT see a modal dialog warning the user is about to leave the secure site. This parameter will be ignored ifdisplayModal
is set to true.msgBoxHeader
: Customize the title of the modal dialog otherwise a default title will showexitMsg
: Customize the message of the modal dialogcancelMsg
: Customize the label on the cancel buttonyesMsg
: Customize the label on the yes buttonexitDomains
: A list of exempt domains that the exit script will not trigger fortargetWarning
: A warning to display to the user that the link will open in a new window. This will append the exit messagedisplayModalForNewWindow
: If set to true, will not display modal for links that open in new window
The attribute cdts-exitscript-disabled
can be added to individual links to exempt them from exit script.
document.write(wet.builder.refFooter({ ... "exitSecureSite" : { exitScript: true, displayModal: true, exitMsg: "This is a custom message. You are about to leave a secure site, do you wish to continue?", cancelMsg: "Nope", yesMsg : "Sure", targetWarning: "Warning: This will open in another window!", exitDomains : "developer.mozilla.org, www.esdc.gc.ca, www.jobbank.gc.ca" } ... }));
Example
The following examples are links that show the modal dialog.
For examples with redirect, please visit here.
- This link https://www.google.ca/ has a host name (google.ca) different from yours. You will see a warning modal dialog.
-
This link https://www.w3schools.com
will open in another window. Through the
targetWarning
parameter, you can set a message that will warn users that the link will open in another window. This message will append the existing display message. - This link breadcrumbs-en.html has the same host name as yours. You won't see a warning modal dialog.
-
This link https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG
has his host name (developer.mozilla.org) in the exception list
exitDomains
. You won't see a warning modal dialog. -
This link https://www.canada.ca/
has the attribute
cdts-exitscript-disabled
exempting it from exit script. You won't see a warning modal dialog.