SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2005
    Posts
    527
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    finding index of frames !

    I have some frames in my pages and I dont want use ID of them because they generate automaticaly

    so how can I send the index of frames to a function for using like this :

    Code:
    function myFunc(indx){
    .
    .
    .
    myObj = window.frames[indx] ;
    .
    .
    .
    }

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bakhanbeigi View Post
    I have some frames in my pages and I dont want use ID of them because they generate automaticaly

    so how can I send the index of frames to a function for using like this :

    Code:
    function myFunc(indx){
    .
    .
    .
    myObj = window.frames[indx] ;
    .
    .
    .
    }
    You would need to identify the correct frame by the url of its document or the content of that document. Assuming all these frames are at the same level in the same frameset and on the same domain, then this function should find a frame according to a specified URL, returning its index or -1 on failure. It excludes its own frame from the search.
    Code:
    function findFrame(url)
    {
     for( var i=0; i<parent.frames.length && parent.frames[i] != self && parent.frames[i].location.href!=url ; i++ )
     ;
    
     return i==parent.frames.length ? -1 : 1;
    }
    You could search for a property or element in a similar manner.
    Tab-indentation is a crime against humanity.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •