SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem in getting a value from iframe

    Hi,

    Im having problem in getting a value from an iframe.

    Here is my code
    <script>
    function IframeFunction()
    {
    var frame = window.parent.frames['frameId'].document.getElementById('helpContent').value;
    alert(frame);
    }
    </script>

    <iframe name="frameId" id="frameId">
    <input type="hidden" id="helpContent" value="colors" />
    <input type="submit" value="submit" onclick="IframeFunction()"/>
    </iframe>

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    U need to put those form elements in an own page. Then you can acces the elements like this:

    Code:
    <script type="text/javascript">
    function IframeFunction()
    {
    	var oIframe = window.frames.frameId;
    	var oIframeBody = oIframe.document.body;
    	alert(oIframeBody.document.getElementById("myDiv"));
    }
    </script>
    
    <iframe src="page.html" id="frameId"></iframe>


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
  •