JS page drop frame method, rating calls between frames; IFRAME goes to the border; custom prompt form; IFRAME goes to the parent form page; IFRAME goes to the scroll bar

Source: Internet
Author: User

1. Document. getelementbyid ("frmid"). contentWindow. function ()

 <  Body  >  <  H1  > Top pages </  H1  >  <  Div  > <  Span  Onclick  = "Callleft ()" > Left Frame Method </  Span  > </  Div  >  <  Div  > <  P  > Left IFRAME </  P  > <  IFRAME  ID  = "Frmleft" SRC  = "Left.htm"  > </  IFRAME  > </  Div  >  </  Body  > 

 

FunctionTopmethod () {alert ('Method from top');}FunctionCallleft () {document. getelementbyid ("Frmleft"). contentWindow. leftmethod ();/*Call the sub-IFRAME Method*//*Get the attributes of the sub-IFRAME*/VaRLeftvar = Document. getelementbyid ("frmleft" 2.16.content20.doc ument. getelementbyid ("leftdiv"). Innerhtml; alert (leftvar );}

Faster call:

VaR ptable shorttop.frmcontrol.doc ument. getelementbyid ('poi _ table_lst '); // frmcontrol is the ID of IFRAME

2. The sub-frame calls the parent htmldoc

 <  Html  Xmlns  = "Http://www.w3.org/1999/xhtml"  >  <  Head  >      <  Title  > </  Title  >      < Script  Type  = "Text/JavaScript"  >          Function  Leftmethod () {alert (  "  Leftmethod  "  );}  Function  Leftcalltop () {top. topmethod (); /*  Method for calling the parent htmldoc  */  }  </  Script  >  </  Head  >  <  Body  >  <  P > Left </  P  >  <  Span  Onclick  = "Leftcalltop ()"  > Top Method </  Span  >  <  Div  ID  = "Leftdiv"  > Left Div </  Div  >  </  Body  >  </  Html  > 

3. Call top. getelementbyid. ("right"). contentWindow. function () on a level frame, that is, left --> top --> right

<Body>

<IFRAME id = "Left">

<IFRAME id = "right">

<Body>

The left frame method calls the right frame:

 

4. B .htmto use a.htm

Window.parent.doc ument

 
<HtmlName= "A.htm"><IFRAMESRC= "B .htm"> <I/Frame><Html>

 

5. other links

Http://www.iteye.com/topic/295075

6. IFRAME de-border

Note: Applicable to IE. It is invalid to write it in CSS. You must directly write it in the tag attribute.

<IFRAME id = "frmcontrol" marginheight = "0" marginwidth = "0" frameborder = "0"> </iframe>

 

7. Custom prompt form

HTML-CSS-js-call

 

Html

 <!  Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"  >  <! --  Add buildings, units, and rooms. Edit the pages of buildings, units, and rooms.  -->  <  Html  Xmlns = "Http://www.w3.org/1999/xhtml"  >  <  Head  >  <  Title  > </  Title  >  <  Link  Href  = "../CSS/addbur.css"  Type  = "Text/CSS"  REL = "Stylesheet"   />  <  Script  Type  = "Text/JavaScript"  SRC  = "../Scripts/addbur. js"  > </  Script  >  </  Head  >  <  Body  > <  Div  ID  = "Window"  >  <  P  ID  = "PTIP"  > <  Span  > Script prompt: </  Span  > <  BR  /> < Span  ID  = "Sptip"  > </  Span  > </  P  > <  P  ID  = "Pbuttons"  > <  Input  Type  = "Button"  ID  = "Inpconfirm" Value  = "OK"  Onclick  = "Confirminput ()"  /> </  BR  > <  Input  Type  = "Button"  ID  = "Inpcancel"  Value  = "Cancel"  Onclick  = "Cancelinput ()" /> </  P  >  <  P  ID  = "Pvalues"  > <  Input  Type  = "Text"  ID  = "Inpvalue"  /> </  P  >  </ Div  >  </  Body  >  </  Html  >  

 

CSS

 * { Margin : 0px ; Padding : 0px ;} P { Font-size :12px ;} # Window { Width : 488px ; Height : 98px ; Margin-top : 10px ;} # PTIP { Width : 358px ; Height : 60px ;Float : Left ; Margin-left : 20px ;} # Pbuttons { Width : 85px ; Height : 55px ; Float : Left ;} # Pvalues { Width :432px ; Clear : Left ; Padding-left : 20px ;} # Sptip { Position : Relative ; Top : 10px ;} # Inpconfirm, # inpcancel { Width : 75px ;Height : 21px ;} # Inpcancel { Position : Relative ; Top : 8px ;} # Inpvalue { Width : 432px ; Border : #8093b9 solid 1px ; Border-collapse :Collapse ;}

 

 

JS

 

 VaR Type; //  Buildings, units, and names  /*  Flag: 0, 1, 2 labels: 0 add; 1 Edit  */  Window. onload = Function  (){  VaR Comb = Window. dialogarguments; initinfo (comb. type, comb. opertype, comb. defval );} Function  Initinfo (flag, opertype, defval ){  If (Flag = 0 ){  If (Opertype = 0) {document. Title = "add building"; sptip. innertext = "enter the building name"; inpvalue. value = Defval ;}  Else {Document. Title = "Edit building"; sptip. innertext = "RENAME building"; inpvalue. value = Defval ;}}  Else   If (Flag = 1 ){  If (Opertype = 0) {document. Title = "Add Unit"; sptip. innertext = "Enter the unit name"; inpvalue. value = Defval ;}  Else {Document. Title = "Edit unit"; sptip. innertext = "RENAME unit"; inpvalue. value = Defval ;}}  Else  {  If (Opertype = 0 ){}  If (Opertype = 0) {document. Title = "add room"; sptip. innertext = "enter the room name"; inpvalue. value = Defval ;}  Else {Document. Title = "edit room"; sptip. innertext = "RENAME room"; inpvalue. value =Defval ;}}}  /*  Cancel  */  Function  Cancelinput () {window. returnvalue = "Canceled "; //  Return Value  Close ();}  /*  OK  */  Function  Confirminput () {window. returnvalue = Inpvalue. value; close ();} 

 

Call

 VaR Comb = {"type": 0, "opertype": 0, "defval": tempnum + "building" };  VaR Dialgattr = 'resizable: No; scroll: Yes; Status: No; dialogheight: 130px; dialogwidth: 500px; center = yes; help = no; status = no' ; Buildingname = Window. showmodaldialog ("addbur.htm" , Comb, dialgattr );  If ( Typeof (Buildingname) = "undefined "){ Return ;} //  Click Close  If (Buildingname = "canceled "){ Return ;} //  Click Cancel  If (Buildingname = "") {alert ("the building name cannot be blank "); Return ;} //  Canceled or the building name is empty 

 

8. IFRAME calls the parent form Method

Window. Parent. imgupdatedcallback (updatedresi); // callback function

 

9. IFRAME go to the scroll bar IE

<IFRAME id = "frmcontrol" marginheight = "0" marginwidth = "0" frameborder = "0" scrolling = "no">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.