[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?
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.
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. :thumb: