Results 1 to 3 of 3

Thread: [JavaScript]Accessing Iframe with IE/FireFox

  1. #1

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Resolved [JavaScript]Accessing Iframe with IE/FireFox

    Grumble!


    Trying to set the contents of a hidden input field of a form inside an iframe to the value of a textbox. In IE I have to use,
    document.frames[0].document.forms[0].sender.value = document.getElementById('txtName').value;

    Which doesn't work in FireFox, but for the FireFox method to work I have to do,

    document.getElementById('sendmessage').contentDocument.frmSend.sender.value = document.getElementById('txtName').value

    Which doesn't work in IE.

    Is there a right or wrong method or something else I've completely missed here?
    Last edited by Pc_Madness; Jun 27th, 2005 at 08:47 PM.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [JavaScript]Accessing Iframe with IE/FireFox

    Different browsers, different methods. You have to perform a check for the browser before calling the code. You can check for document.all or document.layers.

  3. #3

    Thread Starter
    PowerPoster Pc_Madness's Avatar
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    2,765

    Re: [JavaScript]Accessing Iframe with IE/FireFox

    Is it possible to do something like,

    if(navigator.appName == "IE") {
    include 'externaliescript.js';
    } else {
    include 'scriptthatworksforeveryoneelse.js';
    }

    Atm, all I can find is importing using the <script> tag which means I can't really deliver the different .JS files.

    Edit: Ahh ok, I can just do document.write to include the file.
    Last edited by Pc_Madness; Jun 26th, 2005 at 02:45 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width