CSS style modification in IFRAME

Source: Internet
Author: User

How to Control CSS in IFRAME outside IFRAME?

 <!  Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"  > 
< Html Xmlns = "Http://www.w3.org/1999/xhtml" Lang = "ZH-CN" >
< Head >
< Meta HTTP-equiv = "Content-Type" Content = "Text/html; charset = gb2312" />
< Title > </ Title >
</ Head >
< Body >
< IFRAME ID = "FF" SRC = "B .htm" > </ IFRAME >
< Input Type = "Submit" Value = "OK" Onclick = "OK ()" />

< Script Language = "JavaScript" >
Function OK ()
{
// Operate CSS in IFRAME
VaR IFRAME = Document. getelementbyidx ( ' FF ' );
VaR Body = Iframe.contentdomaindoc ument. Body;

Body. style. margintop = 50 ;
Body. style. padding = 0 ;
Body. style. fontsize = 30 ;
Body. style. textalign = ' Center ' ;
Body. style. backgroundcolor = ' Red ' ;
Body. style. Color = ' Blue ' ;
}
</ Script >
</ Body >
</ Html >

This is feasible, provided that the IFRAME is in the same domain as your page. If var IFRAME = Document. getelementbyid ('ff ') is cross-domain, the error "no access permission" is returned ".

the question is how to modify the style in the IFRAME for cross-origin .. To be resolved ..

Related Article

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.