How to solve the same-origin access problem in Chrome under win

Source: Internet
Author: User
Tags unsupported

Introduction: originally wanted to verify that if you have more than one frame in a Web page, there will be more than two different global environments, and if you refer to another frame's data, such as array A, from one frame, then use instanceof Determine if this array A is an instance of another frame array, so the HTML code is as follows

Index.html:

1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en">2 <HTML>3 <Head>4 <title>New Document</title>5 </Head>6 <Framesetcols= "20%,80%">7       <Framesrc= "link.html"name= "link" />8       <Framesrc= "show.html"name= "Show" />9 </Frameset>Ten </HTML>

Link.html:

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4   <title></title>5 </Head>6 <Body>7 <Scripttype= "Text/javascript">8   varArrorder=[];9 </Script>Ten </Body> One </HTML>

Show.html:

1 <!DOCTYPE HTML>2 <HTML>3 <Head>4   <title></title>5 </Head>6 <Body>7 <buttononclick= "Console.log (self.parent.link.arrOrder instanceof Array)">Click</button>8 </Body>9 </HTML>

In Firefox and IE console can normally output false (verify the use of instanceof to determine whether an object is an array of the drawbacks)

But the chrome console output:uncaught securityerror:blocked A frame with origin "null" from accessing a frame with origin "null". protocols, domains, and ports must match.

This is a problem caused by the chrome homology policy, and not only when the IFRAME accesses each other, but also when you need to load files locally or cross-domain access via AJAX or Get and post methods, or there will be no JSONP.

Solution :StackOverflow Dafa Good

Http://stackoverflow.com/questions/3102819/disable-same-origin-policy-in-chrome

I only refer to the solution under win platform, Linux,osx platform can refer to the link ha

For Windows go into the command prompt and go to the folder where Chrome.exe is and type

chrome.exe --disable-web-security

That's should disable the same origin policy and allow you to access local files.

Tip:make sure you are closed all chrome processes and then try again. Chrome would issue a warning header if you had done it correctly: "Your is using an unsupported command-line flag:--disab Le-web-security. Stability and security would suffer "

The way to do this is to right-click the browser shortcut, add the arrows to save the content, and then restart the browser is OK, but Chrome will prompt you "you are using unsupported command line tag:--disabled-web-security, stability and security will be reduced", It's good to test your project without having to worry about it.

Summary : There is more than one solution to cross-domain request resolution. Interested in Access to http://slashlook.com/articles_20140523.html

Chrome also has a plugin artifact that specifically addresses cross-domain issues in AJAX requests: https://chrome.google.com/webstore/detail/allow-control-allow-origi/ nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en

How to solve the same-origin access problem in Chrome under win

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.