SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question calling a function in parent page through iframe?

    Hello

    I have an iframe (code below).. what i want to check is whether this iframe has lloaded or not and if not loaded load another page(by javascript checking in main page)

    Code:
    <div style="font-family:Georgia, "Times New Roman", Times, serif">
    <IFRAME NAME="mainframe" id="mainframe"  FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=580 HEIGHT=100  style="position:relative; left:16px; margin-top:90px;" onload="genurl1('/cgi-bin/nph-gov.cgi')"></IFRAME>
    </div>
    What im trying to do is make the iframe call a function in main page (which on call assigns a value to a variable.and if that variable is set i can know the page has loaded and if that variable is not set ,the iframe has not loaded)

    NOTE:the iframe src is from another domain

    I need help on gng about doing this. ...as the iframe src is another domain and will i be able to call a function in in main page thru the iframe..and assign a value.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    iirc

    parent.functionname();


  3. #3
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but will parent.functionname() call from an external domain loaded iframe have any impact on the the parent..in which the iframe is called...

    hrd thats a javascript bug..and firfefox 2 and IE 7 got a fix for it..
    any way get it working..across domains..someone pls help!

  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,561
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not really sure on this but does javascript let the windows/frames from different domains to communicate with each other? I thought there was some sort of 'same domain' policy which prevented that.

  5. #5
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think there are any hacks to get over this, other than using a server side code ie PHP's cUrl to get the page within the iframe and display it via your own domain.



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
  •