IFRAME uses global CSS styles

Source: Internet
Author: User

A friend who has used the Rich Text Editor may know that the content written in the editor, if there is a style change, when the webpage is displayed, it may be quite different from what you write. The reason is that global CSS is defined on the page. So how can we avoid global CSS? You can use IFRAME to process it .....

 

Example:

 

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <br/> <HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "ZH" lang = "ZH" dir = "LTR"> <br/> <pead> <br/> <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8 "/> </P> <p> <title> IFRAME avoids global CSS styles </title> <br/> <SCRIPT src =" http://code.jquery.com/jquery-latest.min.js "> </script> <br/> <SCRIPT type = "text/JavaScript"> <br/> $ (function () {<br/> var contents =$ (": hidden [name = contents]"). val (); <br/> $ ("# ifecontents "). CONTENTS (). find ("body "). append (contents); <br/> // IFRAME automatically adapts to the text content height <br/> window. setinterval ("reinitiframe ()", 200); <br/> }); <br/>/** <br/> * reinitiframe <br/> * @ return void <br/> */<br/> function reinitiframe () {<br/> var IFRAME = $ ("# ifecontents") [0]; <br/> var bheight = iframe.content+doc ument. body. scrollheight; <br/> var dheight = iframe.content?#document.doc umentelement. scrollheight; <br/> var Height = math. max (bheight, dheight); <br/> IFRAME. height = height; <br/>}</P> <p> </SCRIPT> </P> <p> </pead> <br/> <body> <br/> <form name = "frm" method = "Post"> <br/> <input name = "contents" type = "hidden" value = "Test Data"/> <br/> <IFRAME id = "ifecontents" frameborder = "0" allowtransparency = "true" tabindex = "0" src = "" style = "width: 100%; "scrolling =" Auto "> </iframe> <br/> </form> <br/> </body> <br/> </ptml>

 

PS:

  • When using IFRAME, pay attention to its "scroll bar". If you do not want to see the scroll bar, you need to make the IFRAME adaptive height. The specific code is written in the above Code.

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.