beautypg.com

Adobe Dreamweaver API Reference CS5 User Manual

Page 371

background image

366

DREAMWEAVER API REFERENCE

Dynamic documents

Last updated 8/27/2013

At the head of the document, you must have a script that looks like the following:

var browserEle = document.getElementById("myBrowser");
alert(browserEle.getWindow().document.documentElement.outerHTML);

The browser control also broadcasts two special events:

BrowserControlLoad

This event is called immediately after the browser has called its load event so that you can attach

your own elements to the loaded browser DOM.

BrowserControlBeforeNavigation

This event is called when the browser is about to go to a new page. If the event is

canceled, the navigation request is also canceled and the browser control remains on its current page. The event
context also contains the requested URL.

The following example illustrates the functionality of these events:

var browserEle = document.getElementById("myBrowser");
browserEle.addEventListener("BrowserControlBeforeNavigation",

function(e){ if (e.requestedLocation = "foo.com")

e.preventDefault(); //don't allow navigation to this site!}, true);

Guidelines for using in Dreamweaver 13.1 and later

Dreamweaver 13.1 and later is integrated with Chromium Embedded Framework (CEF3). Prior to Dreamweaver 13.1,
communication between Dreamweaver and used to be a synchronous. Since CEF3 is an
asynchronous platform, the way Dreamweaver communicates with has changed.Now, each
instance of spawns off new processes called 'Render processes'. These processes are responsible
for rendering the content loaded in .This document provides guidelines for using
taking into account the asynchronous nature of communication and multi-process
architecture of CEF, while developing your extensions.

Call getWindow in valid scope
Now, the window object is created only when LoadURL or LoadHTML is called and completed. So, the window object
of Live view is to be accessed only after BrowserControlLoad event is triggered. (This event is triggered when the Live
View browser is ready).Note: Calling "getWindow" function before the browser is ready returns an "undefined" object.
During subsequent accesses, the object causes exception in JS execution.

Example:

Prior to Dreamweaver 13.1

function Init_MM_browsercontrol()
{
var cefBrowser = document.getElementById("liveBrowser");
cefBrowser.openURL("extention.html");
var liveViewWindow = cefBrowser.getWindow();
liveViewWindow.initDefaults();
}