For the third party integration, the author used & LT; iframe> , through the js of the child page to adjust the elements of the parent page, there will be access to the situation. The reason for this problem is that js does not belong to the same domain, so it is forbidden to access due to the security problem of some browsers.
resources: https://developer.mozilla.org/Cn/JavaScript the same-origin policy (such as can not access, HTTP) instead of HTTPS for
File: http://sub.xxx.com/index.html
& lt; ! doctype html>
< html>
< head>
…
< /head>
< body>
…
& lt; iframe id=”iframe_xxxx” name=”iframe_xxxx” src =”http://www.xxx.com/sub.html” frameborder=”0″ height=”300″ width=”1000″> < /iframe>
< /body>
< /html>
File: http://www.xxx.com/sub.html
& lt; ! doctype html>
< html>
< head>
< script type=”text/javascript”>
// set domain information
document.domain = ‘xxx.com’;
// set domain information
document.domain = ‘xxx.com’;
// set the iframe height of the parent page to reference itself
function setHeight(){
//
if(window.top! = window. Self) {
the parent. The document. The getElementById (‘ iframe_xxxx). Height = document. The body. The scrollHeight + 20
}
} & lt; /script>
< /head>
< Body &western nl &western AD = “setHeight ();” >
…
< /body>
< /html>
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
the problem is caused by the browser’s security mechanism,
but it is under the same domain subdomain and secondary subdomain difference, can be solved.
the solution is to change the domain information of the two pages to be the same.
because the default page’s domain information contains the second-level domain, this setting allows the use of the top-level domain as the domain information.
< script type=”text/javascript”>
document.domain = ‘xxx.com’;
< /script>
Note: This method is not feasible if two pages do not belong to the same domain name. Forced setting js will report an error. Addition: if we are not sure whether the referenced page is in the same domain as the referenced page, we can determine this by obtaining the url address of the referenced page
< script type=”text/javascript”>
//document.referrer – returns the URL of the document that was loaded with the current document.
$p_url = document.referrer;
< /script>
//= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Reference: http://hi.baidu.com/eecc00/item/7c99477420e9f1345c1789e3
Read More:
- CSS: several ways to center the box vertically and horizontally
- NS_ERROR_DOM_BAD_URI: Access to restricted URI denied
- How to use JavaScript in HTML
- JavaScript summary: the difference between typeof and instanceof, and Object.prototype.toString() method
- How to center the box horizontally and vertically in HTML
- JavaScript to achieve image rotation effect
- window.open () several ways to open windows
- JS opens a new tab( window.open Application)
- Asynchronous loading JS does not allow the use of document write solution
- If the iframe in IE refers to the cross domain site page, the session fails
- Three methods of JavaScript jump to new page
- Error: permission denied to access property “ref”
- JavaScript / JS native dynamic introduction of external CSS files and dynamic insertion of CSS code fragments
- How to center your HTML button itself? ——Use the align attribute of center or Div
- Android layout: layer layout
- Android solves the gliding problem of EditText
- Uncaught typeerror: cannot set property ‘of null error resolution
- PHP & nbsp; built in server array
- Android gets the height and width of the screen
- Uncaught domexception: failed to read the ‘contentdocument’ property from ‘htmliframeelement’