[MacEd] Re: Trying to learn to use the macro editor

Biju G C bijumaillist at yahoo.com
Thu Oct 2 21:59:33 EDT 2003


In the macro javascript "window" will give the "ChromeWindow" 
object, which is the firebird/Mozilla browser app window
and "document" will give XULDocument object of the browser app.
To access the currently viewing HTML document window we 
should use either "window._content" or currently focused frame window
by "document.commandDispatcher.focusedWindow".
And the HTML document can be accessed by "window._content.document" 
or currently focused frame HTML document by 
"document.commandDispatcher.focusedWindow.document".
Once you get HTML window or document objects other objects can 
be easly accessed in the same way we do in normal javascript.

Following Macro is the demo of how to access objects of 
current HTML page.


function getBrowserWin(){
 return window._content;
}

function getFocusedFrameWin(){
 return document.commandDispatcher.focusedWindow
}


function getBrowserDoc(){
 return window._content.document;
}

function getFocusedFrameDoc(){
 return document.commandDispatcher.focusedWindow.document;
}

function getWinInfo(win){
 var a=[];
 a.push('Location : ' + win.location); 
 a.push('Name : ' + win.name); 

 var doc=win.document;
 if(doc) {
   a.push('Title : ' + doc.title ); 
   a.push('Referrer : ' + doc.referrer); 
   a.push('LastModified : ' + doc.lastModified); 
   a.push('Cookies: ' +( doc.cookie?'\n=> '+doc.cookie.split(';').join('\n=> '):'none'));
   a.push('Links: ' + (doc.links.length?doc.links.length:'none'));
   a.push('Forms: ' + (doc.forms.length?doc.forms.length:'none'));
   a.push('Images: ' + (doc.images.length?doc.images.length:'none'));
 }
 a.push('Status : ' + win.status); 
 a.push('Sub Frames : ' + (win.frames.length?win.frames.length:'none'));
 return a.join('\n'); 
}

var mainwin = getBrowserWin();
var s;
s=getWinInfo(mainwin);
alert('WINDOW INFO\n\n'+s);
var framewin = getFocusedFrameWin();
if(framewin && (framewin != mainwin)){
    s=getWinInfo(framewin);
    alert('CURRENT FRAME INFO\n\n'+s);
}




________________________________________________________________________
Want to chat instantly with your online friends?  Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk


More information about the Macroeditor mailing list