Get introduced elements within the iframe page

 

In web development, often used iframe, will inevitably encounter need to use iframe element in the parent window, or use the element of the parent window in the iframe framework.

js

acquires the parent window in the iframe element

1.

Format: window.frames [ "iframe's name value"] .document.getElementById ( "ID iframe in control") click ();.
Example: window.frames [ " IFM. "] document.getElementById (" btnOk ") the Click ();.

 2.

    format:
    var obj = document.getElementById (" iframes the name "). contentWindow;
    var = ifmObj obj.document.getElementById (" the controls iframes the ID ");
    ifmObj.click ();
    example:
    var obj = document.getElementById (" IFM; ") contentWindow.
    btnOk"); var = ifmObj obj.document.getElementById ( "
    ifmObj.click ();

 in the iframe get the parent window elements

format: window.parent.document.getElementById ( "
Example: window.parent.document.getElementById ( "btnOk") the Click ();.

 

JQuery

obtaining an iframe element in the parent window

1.

Format: $ ( "# iframe's ID") contents () find ( ".. #iframe the control ID ".) click (); // jquery method 1
example: $ (" # ifm ") contents () find (.." # btnOk ") click (); // jquery 1.

2 .

format: $ ( "# iframe the control ID", document.frames ( "frame's name") document.) .click ( ); // jquery method 2
example: $ ( "# btnOk", document.frames ( "ifm") document) .click ( ); // jquery method.

 Gets the parent window in the iframe element

format: $ ( '# parent window elements in ID', parent.document) .click () ;
example: $ ( '# btnOk', parent.document) .click

   
(); ----------------
copyright: original article is CSDN blogger "skysky_1989", and follow CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.

Guess you like

Origin www.cnblogs.com/PHP0222wangdong/p/11478176.html