Results 1 to 3 of 3

Thread: how to call function from iframe and from iframe to back again

  1. #1
    Join Date
    Oct 2008
    Posts
    40
    Thanks
    3
    Thanked 1 Time in 1 Post

    Smile how to call function from iframe and from iframe to back again

    hello

    how to call javascript function from iframe to normal page (that has included iframe) and from normal page to iframe.

    please replay .........

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    The following code calls the function that exists in the main window from the iframe window

    Code:
    if(typeof parent.window !== 'undefined' && typeof parent.window.functionName === 'function'){
    	functionName(); //Call the function only if it exists
    }
    The following code calls the function that exists in the iframe window from the main window
    Code:
    if(typeof document.frames['iframeName'] !== 'undefined' && typeof document.frames['iframeName'].functionName === 'function'){
    	document.frames['iframeName'].functionName(); //Call the function available in the iframe window from the parent window.
    }
    Please note that here the functionName can be replaced with the function names that you want to access. I've used a dummy name like this to convey the idea.
    Hope this helps.

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
  •