ssCore.Browser.setNotify

Tell SWF Studio about an event that you want to receive notifications for.


Availability:

First available in version 3.0 build 2039.


Input Parameters:

event - The event you want to receive notifications for. Valid values include: onActiveElementChange, onBlockedPopup, onBlockedURL, onDocumentComplete, onMouseButton, onNavigate, onPreview, onProgress, onStatus, onTitle, and onWindowClosing.


Output Parameters:

href - An optional parameter used with OnActiveElementChange to return the HREF of the active element (in addition to the outerHTML that is returned by default).

result - Notification data for the specified event (see description of events for more detail).


Asynchronous Mode:

When this method is called asynchronously, a return object containing the output parameters is passed to the specified callback function.

ssCore.Browser.setNotify( paramsObject [, callbackParamsObject] [, errorParamsObject] );


Synchronous Mode:

When this method is called synchronously, a return object containing the output parameters is returned to the caller immediately.

var returnObject = ssCore.Browser.setNotify( paramsObject );


Notes:

None.


Events:

name - onActiveElementChange
type - triggered
result - "html"
href - "href"

onActiveElementChange is triggered when the active element in the browser window is changed, i.e. when the user clicks on a new element. The data received by the event handler is the outer html of the selected element.

The onActiveElementChange also has an extra output parameter called href that is the HREF of the active element.

ssCore.Browser.setNotify({event:"onActiveElementChange"}, {callback:onActiveElementChange});

function onActiveElementChange(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("HREF: " + ret_obj.href);
        ssDebug.trace("outerHTML: " + ret_obj.result);
    }
}

name - onBlockedPopup
type - triggered
result - "URL"

onBlockedPopup is triggered when Browser.allowPopups has been set to false and an attempt is made to open a resource in a new window. The data received by the event handler is the URL of the blocked popup.

ssCore.Browser.setNotify({event:"onBlockedPopup"}, {callback:onBlockedPopup});

function onBlockedPopup(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("blocked popup: " + ret_obj.result);
    }
}

name - onBlockedURL
type - triggered
result - "URL"

onBlockedURL is triggered when the Browser object has blocked a URL based on rules supplied by Browser.addRule. The data received by the event handler is the blocked URL.

ssCore.Browser.setNotify({event:"onBlockedURL"}, {callback:onBlockedURL});

function onBlockedURL(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("blocked URL: " + ret_obj.result);
    }
}

name - onDocumentComplete
type - triggered
result - "url"

onDocumentComplete is triggered when a document has been completely loaded an initialized by the browser. The data received by the event handler is the URL of the loaded document in the browser. The last onDocumentComplete event fired in response to a URL change is what your browser displays in the address bar after the requested document is fully rendered. You may receive multiple onDocumentComplete events for a single URL change if the main document contains frames.

ssCore.Browser.setNotify({event:"onDocumentComplete"}, {callback:onDocumentComplete});

function onDocumentComplete(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("document complete: " + ret_obj.result);
    }
}

name - onNavigate
type - triggered
result - "url"

onNavigate is triggered when the URL of the browser is changed and navigation is completed on either a window or frame. It doesn't matter whether the change was initiated by calling a Browser command or as a result of the user clicking on a link in the browser window. The data received by the event handler is the URL of the page that was navigated to. You may receive multiple onNavigate events for a single URL change if the main document contains frames.

ssCore.Browser.setNotify({event:"onNavigate"}, {callback:onNavigate});

function onNavigate(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("navigated to: " + ret_obj.result);
    }
}

name - onPreview
type - triggered
result - "url"

onPreview is triggered just before the URL of the browser is changed. It doesn't matter whether the change was initiated by calling a Browser command or as a result of the user clicking on a link in the browser window. The data received by the event handler is the URL of the page that the browser is about to show. If you call Browser.setURL in the onPreview handler you can effectively block the browser from displaying the URL that triggered the onPreview event.

ssCore.Browser.setNotify({event:"onPreview"}, {callback:onPreview});

function onPreview(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("next URL: " + ret_obj.result);
    }
}

name - onProgress
type - triggered
result - "progress,maxbytes"

The onProgress event is triggered when the progress bar in the status area of IE would normally be displayed i.e. for downloading large pages and graphics. The data received by the event handler contains two values progress and maxbytes that tell you the current progress in bytes and the maximum amount of data available to be downloaded. For example "100,1000" means 100 of 1000 bytes.

ssCore.Browser.setNotify({event:"onProgress"}, {callback:onProgress});

function onProgress(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        var v = ret_obj.result.split(",");
    
        var n = Number(v[0]);
        var t = Number(v[1]);
             p = n/t*100;
        if (p < 1 || p > 99) p = 0;
    
        ssDebug.trace("progress: " + p + "%");
    }
}

name - onStatus
type - triggered
result - "text"

The onStatus event is triggered when the browser status text changes. This normally happens when the users moves the mouse over images and links, but the status text can also be set by VBScript or JavaScript on the page being viewed. The data received by the event handler contains the new status text.

ssCore.Browser.setNotify({event:"onStatus"}, {callback:onStatus});

function onStatus(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("status: " + ret_obj.result);
    }
}

name - onTitle
type - triggered
result - "text"

The onTitle event is triggered when the browser title text changes. This happens when the browser parses a TITLE tag, or when the title is changed by a script running on the page. The data received by the event handler contains the new title text.

ssCore.Browser.setNotify({event:"onTitle"}, {callback:onTitle});

function onTitle(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("status: " + ret_obj.result);
    }
}

name - onWindowClosing
type - triggered
result - "ignore"

The onWindowClosing event is triggered when the page attempts to close the browser window using JavaScript. The Browser will prevent the window from closing but will send you this notification to let you know the attempt was made. The data received by the event handler can be ignored.

ssCore.Browser.setNotify({event:"onWindowCloseing"}, {callback:onWindowClosing});

function onWindowClosing(ret_obj, cb_obj, err_obj)
{
    if (ret_obj.success)
    {
        ssDebug.trace("the page has attempted to close the browser window");
    }
}