HTML5 Viewer SDK API Documentation 


Class Index

Classes in s7sdk.common

Class s7sdk.common.CloseButton

Extends s7sdk.common.Button.

The CloseButton is used to close the viewer's browser window when the window is opened using JavaScript.

This component does not currently read any modifiers.

Defining the Appearance using CSS

The CSS class for styling the CloseButton is .s7closebutton. This button has four states: up, over, down and disabled. You can style these states by adding the state attribute selector to the CSS class. It is recommended that you define common CSS under the main class and only define the necessary distinctions when using attribute selectors.

CSS ClassAttribute SelectorDescription
.s7closebuttonstate=[up|over|down|disabled]Define the appearance of CloseButton for the various states.
.s7tooltip(None)A global class selector that defines appearance for the tooltips. To disable tooltips set the display style to none.

Localized Symbols

CloseButton also has text symbols that you can localize either in a preset or in the viewer page though the mechanisms provided by the ParameterManager. For more information on localization consult the ParameterManager API documentation and HTML5 Viewers SDK User Guide.

CloseButton.TOOLTIPDefine a localized tooltip of CloseButton

Class Summary
Constructor Attributes Constructor Name and Description
s7sdk.common.CloseButton(container, settings, compId)
Methods borrowed from class s7sdk.common.Button:
activate, addEventListener, blur, deactivate, dispose, focus, getHeight, getWidth, resize, setCSS, setLabel
Class Detail
s7sdk.common.CloseButton(container, settings, compId)
Example Code

This example demonstrates how to use the CloseButton component in a simple viewer. In this example a Container object, a ZoomView object, and a CloseButtonButton object are created. Clicking the close button closes the Web browser window which contains the viewer. The code below does the following:

  1. The Scene7 HTML5 SDK is linked to the page and the required s7sdk components are included in the document head.
  2. CSS Styles are defined in the document head to control the appearance of the ZoomView and CloseButton components.
  3. The s7sdk.Util.init() method is called to initialize the SDK.
  4. A ParameterManager object is created to handle component modifiers for the viewer.
  5. An initViewer() function is defined. This function initializes a couple of modifiers (hard coded for example purposes), then creates the component objects required for this simple example. The initViewer() function also adds event listeners that designate functions to handle relevant component events (which might be dispatched by the components as a result of user interactions, changes in a component's state, etc.).
  6. A handler function is defined to respond to the component event listener added in the initViewer() function.
  7. An event listener is added to the ParameterManager object that designates the initViewer() function as the handler to call when the Scene7 SDK is loaded and ready.
  8. Finally, the init() method is called on the ParameterManager object to start the viewer.
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="user-scalable=no, height=device-height, width=device-width, initial-scale=1.0"/> <title>Close Button Example</title> <!-- To run this example locally you need to replace this with an absolute SDK path. For more information check the HTML5 Viewers SDK User Guide or the examples included in the package. --> <script language="javascript" type="text/javascript" src="../js/s7sdk/utils/Utils.js"></script> <script language="javascript" type="text/javascript"> s7sdk.Util.lib.include('s7sdk.common.Container'); s7sdk.Util.lib.include('s7sdk.common.Button'); s7sdk.Util.lib.include('s7sdk.image.ZoomView'); </script> <style type="text/css" media="screen"> .s7zoomview { top: 0px; left: 0px; height: 400px; width: 280px; } .s7closebutton{ position: absolute; top: 0px; left: 280px; width: 30px; height: 30px; } </style> </head> <body> <script language="JavaScript" type="text/javascript"> var params, container, zoomView, closeButton; // Initialize the SDK s7sdk.Util.init(); // Create a ParameterManager instance to handles modifiers params = new s7sdk.ParameterManager(); // Define the function that initializes the viewer function initViewer(){ // Set hardcoded modifiers (not required when values are specified on the url) params.push("serverurl", ""); params.push("asset", "demo/bedroom.tif"); // Create the viewer Container component object container = new s7sdk.Container(null, params, "s7container"); // Create ZoomView component object zoomView = new s7sdk.image.ZoomView(container, params, "zoomView"); // Create CloseButton component object closeButton = new s7sdk.CloseButton(container, params, "closeBtn"); // Add event listener for closeButton click events closeButton.addEventListener("click", onCloseContainer); } // Define an event handler function to close the window when the user clicks the close button function onCloseContainer(event){ try{ if( != "firefox"){ //workaround for close self window with JS"s7sdkclose.html","_self"); }else{ // Firefox does not allow the workaround so we fall back to window.close to cover this pop-up case // Note: If dom.allow_scripts_to_close_windows is not set to true in Firefox settings this cannot work. window.close(); } }catch(e){ s7sdk.Logger.log(s7sdk.Logger.WARN, "Cannot close the window"); } } // The ParameterManager will dispatch SDK_READY when all modifiers have been processed // and it is safe to initialize the viewer params.addEventListener(s7sdk.Event.SDK_READY, initViewer, false); // Now it is safe to process the modifiers, the callbacks have been defined // this will trigger the SDK_READY event params.init(); </script> </body> </html>
Default styles for CloseButton:

.s7closebutton {
.s7closebutton[state='up'] {
.s7closebutton[state='over'] {
.s7closebutton[state='down'] {
.s7closebutton[state='disabled'] {
.s7tooltip {
	background-color:rgb(224, 224, 224);
	font-family:Helvetica, sans-serif;
	border:1px solid rgb(191,191,191);
{String|Container} container
The reference to Container instance, ControlBar instance or the ID of the parent DOM element to which the component is added as a child
{s7sdk.ParameterManager} settings
ParameterManager as settings.
{String} compId
A unique ID for this component.

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Oct 15 2020 11:59:11 GMT-0000 (UTC)