1. IE-specific (image positioning through frames index): document.frames[i].document.getElementById('Id of element');
2. IE-specific (image positioning through IFRAME name): document.frames['iframe' name'].document.getElementById('Id of element');
The above method is not only applicable to IFRAME, but also to FRAME in FRAMESET. Although IE is good at setting custom standards, it has to be said that many of its designs still reflect humanity. For example, this one provides a concise and visual writing method in addition to the standard path below.
3. General method: document.getElementById('Iframe' ID').contentWindow.document.getElementById('Id of element')
Note that contentWindow is added. Often, problems occur because this is easy to be ignored. It represents the window objects inside FRAME and IFRAME.
However, it is obvious that this writing style is very fatal and too long. If you want to operate a series of elements, it will be really worth writing this way. Even if you use the copy-paste method, your eyes will look like a problem.
4. Abbreviation of general methods:
Define a short name for document.getElementById, and friends who are a little familiar with JS know this method. Here it can double the function, as shown in the following example:
var $id=document.getElementById;$Id('iframe' ID').contentWindow.$Id('element') //This way you get the object to be takenAt this point, I still like the IE approach and care more about it. Because Microsoft is not a separate browser developer, it also needs to write and develop HTML/ASP and other documents in large quantities, so it is more able to do this. Other browser developers basically only stand on the standpoint of one browser, and just follow the most basic links and rarely design some shortcuts like this that are both simple and semantic. Many people often say that they are "standard". Although it makes sense in some places, in some places, this standard is just a kind of indifference.
The above article quickly obtains/sets the js implementation methods of object elements in an iframe are all the content I have shared with you. I hope you can give you a reference and I hope you can support Wulin.com more.