当前位置:网站首页>Iframe is simple to use, iframe is obtained, iframe element value is obtained, and iframe information of parent page is obtained

Iframe is simple to use, iframe is obtained, iframe element value is obtained, and iframe information of parent page is obtained

2022-06-25 08:28:00 Pursue ~

1.iframe Easy to use

<iframe> The label specifies an inline framework .

An inline framework is used in the current HTML Embed another document in the document .

<iframe width=420 height=330 frameborder=0 scrolling=auto src=URL></iframe>

  • width Insert the width of the page ;
  • height Insert page height ;
  • scrolling Whether to display the page scroll bar ( The optional parameters are auto、yes、no, If you omit this parameter , The default is auto);
  • frameborder The frame size ;

Be careful :URL Absolute path is recommended

<iframe width=0 height=0 frameborder=0 scrolling=auto src=WWW .webjx.com></iframe>

If a page has a frame , Click the link in the page , Request in this <iframe> Open in . stay <iframe > Specified in the name

<iframe name=**  ></iframe>

Then change the default open mode ,: Webpage head Medium plus <a href=URL target=**> Or partially connected target frames are set to (**)

To insert a page . Ask for only the middle part . Nothing else .

Code :

<iframe name=123  align=middle marginwidth=0 marginheight=0 vspace=-170 hspace=0 src="http://www.webjx.com/"  frameborder=no scrolling=no  width=776  height=2500></iframe>

Controls the depth at which the inserted page is covered by the frame marginwidth=0 marginheight=0; Control the depth of the upper part covered by the frame vspace=-170

scrolling Scroll bar Yes No (auto、yes、no) frameborder Frame border size ,width=776 height=2500 The size of this frame .

2. obtain iframe

Common methods of getting elements ,dom ,jQ etc. ;

var ifr = document.getElementById(‘mainIframe0’)

3. obtain iframe Element value

ifr.contentWindow

Get is window object

Window {
    postMessage: ƒ, blur: ƒ, focus: ƒ, close: ƒ, parent: Window,}

ifr.contentWindow. value Defined global variables .

4.iframe Get the information of the parent page :

Get the value of the parent page element :

jquery The way :$("#auditDate",parent.document).val();

js The way :parent.document.getElementById(“auditDate”).value;
原网站

版权声明
本文为[Pursue ~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/176/202206250701333190.html