[Project_owners] getElementsByTagName() problem

Michael Johnston special.michael at gmail.com
Tue Apr 11 22:43:31 EDT 2006


not looked at the page you link to but the first thought I have is
frames in frames or iframes in iframes.

the solution to which would be recursive search

function getInputs(stack, doc){
   // current doc
   var fields = doc.getElementsByTagName("input");
   for (var i=0; i<fields.length; i++)
        stack.push(fields[i]);

   // Check frames
   var frames = doc.getElementsByTagName("frame");
   for (var i=0; i<frames.length; i++) {
         getInputs(stack, frames[i].contentDocument);
   } //frames

   // Check iframes
   var frames = doc.getElementsByTagName("iframe");
   for (var i=0; i<frames.length; i++) {
        getInputs(stack, frames[i].contentDocument);
   }//iframes

} //getinputs

 doc = recentWindow.content.document;
 // Build an array of all <input/> elements
 // in the doc (including frames)
 var inputFields = new Array();

 //call recursive func
 getInputs(stack, doc);


mike

On 4/11/06, Eric H. Jung <grimholtz at yahoo.com> wrote:
> Hi,
>
> The following code, which build an array of all <input/> elements on a page,
> works at every website I've tried except
> https://banking.ing-diba.de/OnlineBanking/index.html.
>
> Would someone be able to have a look? I cannot figure out why.
>
> Context is browser.xul scope with
> https://banking.ing-diba.de/OnlineBanking/index.html loaded:
>
> var recentWindow = Components.classes["@mozilla.org/appshell/window-mediator;1"]
>   .getService(Components.interfaces.nsIWindowMediator)
>   .getMostRecentWindow("navigator:browser");
>
> if (recentWindow) {
>   doc = recentWindow.content.document;
>   // Build an array of all <input/> elements
>   // in the doc (including frames)
>   var inputFields = new Array();
>
>   // Check doc
>   var fields = doc.getElementsByTagName("input");
>   for (var i=0; i<fields.length; i++)
>     inputFields.push(fields[i]);
>
>   // Check frames
>   var frames = doc.getElementsByTagName("frame");
>   for (var i=0; i<frames.length; i++) {
>     fields = frames[i].contentDocument.getElementsByTagName("input");
>     for (var j=0; j<fields.length; j++)
>       inputFields.push(fields[j]);
>   }
>
>   // Check iframes
>   var frames = doc.getElementsByTagName("iframe");
>   for (var i=0; i<frames.length; i++) {
>     fields = frames[i].contentDocument.getElementsByTagName("input");
>     for (var j=0; j<fields.length; j++)
>       inputFields.push(fields[j]);
>   }
>
> Thank you in advance for your time,
> Eric Jung
>
> Use Your PC To Find a Cure for Cancerhttp://members.ud.com/services/teams/team.htm?id=68C9E079-8285-495F-8598-D73352CC7075And Join Team Lulu
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
>


More information about the Project_owners mailing list