How to access element in an iFrame on same page?

Discussion in 'JavaScript' started by wll6568, Nov 16, 2008.

  1. #1
    I am trying to access a text field value which resides in an iframe:

     function getField(iframeid,iframename,fieldId){
                var mmspobj=parent.document.getElementById(iframeid);
                if (mmspobj.tagName=='IFRAME'){
                     mmsiobj=window.frames[iframename].document.getElementId(fieldId).value;
                     return mmsiobj;
                  }
            }
    Code (markup):
    But that gives the error:

    Permission denied to get property Window.document
     
    wll6568, Nov 16, 2008 IP
  2. rohan_shenoy

    rohan_shenoy Active Member

    Messages:
    441
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    60
  3. elias_sorensen

    elias_sorensen Well-Known Member

    Messages:
    852
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    110
    #3
    If it's not your site shown in the iframe, you'll probably don't have the permission to access it with javascript :)
     
    elias_sorensen, Nov 17, 2008 IP
  4. kiks

    kiks Banned

    Messages:
    269
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try this:

    alert(window.frames[0].document.getElementById('myId').value);

    If you don't manage, message me and i will send you the full example
     
    kiks, Nov 17, 2008 IP