SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Iframe

  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Iframe

    Hey,

    How do I access the document that is inside an IFRAME? Something like this (this doesn't work )
    Code:
    document.getElementById('iframe').document.getElementById('field1').value;

  2. #2
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    frames['iframe1'].document.getElementById('field1').value = 'ta da!';
    
    ...
    
    <iframe id="iframe1' name="iframe1"></iframe>
    You need to use it as it is shown; do not use document.frames[] and be sure to use the name attribute in the <iframe> tag.

    p.s. don't forget that <iframes> are not valid/compliant with Strict DTDs.


    Hope that helps
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    OK, thanks for the reply Here is my function
    PHP Code:
    function moveIdea where ) {
        if ( !
    document.getElementById('ideaForm').target ) {
            
    document.getElementById('ideaForm').target 'hiddenFrame';
        }
        
    document.getElementById('hiddenFrame').src 'db/ideaRecords.php?where=' where;
        
    document.getElementById('id').value frames['hiddenframe'].document.getElementById('id').value;
        
    document.getElementById('a').value frames['hiddenframe'].document.getElementById('title').value;
        
    document.getElementById('b').value frames['hiddenframe'].document.getElementById('text').value;
        
        
    document.getElementById('ideaForm').submit();
        
        return( 
    true );

    but it doesn't work In Opera 7 I get no errors but nothing happens.

    Any ideas?

    PS. I'm off ot try in IE now.

  4. #4
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Alrighty, in IE6, I get an Object Expected error and the line it tells me is the line where this function is called.

    It's called at <body onLoad="moveIdea('start');"> and when a button is pressed, the line containing the error is the button line and the error only comes up when I press the button.

  5. #5
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you have a link where I can see the whole thing online?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  6. #6
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Unfortunately I don't, I will look into possibilities and post back.

    Thanks for the help so far


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
  •