www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-20-2009, 11:04 AM
    dareno dareno is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 4
    Can't get content of the iframe node

    I want to display content of the iframe node <mydata>. But it not works, it just display empty message. I work on IE8.
    My code:
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function show() {
      var v = window.frames['IF'].document.body.innerHTML;  //gives empty message
    //var v = window.frames['IF'].document.getElementById('MY').firstChild.nodeValue;   //gives error
      alert(v);
    }
    </script>
    </head>
    
    <body>
    <form>
    <input type="button" value="but" onclick="show()" />
    </form>
    
    <iframe name="IF" id="IF">
    <html>
    <body> 
    <mydata id="MY">ala </mydata>
    </body>
    </html>
    
    </iframe>
    </body>
    </html>
    Reply With Quote
      #2  
    Old 11-20-2009, 11:10 AM
    dareno dareno is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 4
    I tried also :
    var v = window.frames['IF'].mydata; //gives undefined
    var v = window.frames['IF'].MY; //gives undefined
    Reply With Quote
      #3  
    Old 11-20-2009, 11:11 AM
    Kor's Avatar
    Kor Kor is offline
    Red Devil Moderator
     
    Join Date: Dec 2003
    Location: Bucharest, ROMANIA
    Posts: 11,522
    I guess you missed the way IFRAME element works:
    http://www.w3schools.com/TAGS/tag_iframe.asp
    An IFRAME loads and displays another HTML file into the document
    Reply With Quote
      #4  
    Old 11-20-2009, 02:58 PM
    dareno dareno is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 4
    This code is just an example. My program is a servlet and the iframe src is redirected to server with get method. Iframe body is filled by server response. I need to display this response from javascript, so i need to display iframe body.
    Reply With Quote
      #5  
    Old 11-21-2009, 01:34 AM
    Kor's Avatar
    Kor Kor is offline
    Red Devil Moderator
     
    Join Date: Dec 2003
    Location: Bucharest, ROMANIA
    Posts: 11,522
    Quote:
    Originally Posted by dareno View Post
    This code is just an example.
    Example of what? I see no SRC attribute inside that IFRAME. The way you have written, everything you coded inside <iframe></iframe> is invisible for modern browsers. If you give an example, give a realistic example.

    For JavaScript, the accuracy of the HTML code is vital. We need to see what JavaScript sees, and JavaScript sees what the browser shows like on View Source.
    Reply With Quote
      #6  
    Old 11-21-2009, 08:23 PM
    criterion9 criterion9 is online now
    B.S. CIS
     
    Join Date: Jan 2009
    Posts: 1,353
    It sounds like a backwards way to do AJAX requests. Is there a reason you are using iframes instead of AJAX?
    Reply With Quote
      #7  
    Old 11-23-2009, 04:18 AM
    dareno dareno is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 4
    Quote:
    Originally Posted by criterion9 View Post
    It sounds like a backwards way to do AJAX requests. Is there a reason you are using iframes instead of AJAX?
    You are right criterion9. But I am pl/sql programmer and now I have to write web application and I don't know java script - I didn't know I can use something like AJAX.
    Previously I tried this method: http://www.ibm.com/developerworks/we...rel/index.html

    Now I used AJAX as you suggested an it works. Thanks.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:38 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.