Here is a simple test page: IE, Firefox pop-up "Hello World", and Chrome,safari,opera no response.
The following is a small section of the test code (deliberately modify domain, so that the parent page and subpage page for different domains):
1. Parent page code:
Copy Code code as follows:
<script>
Document.domain = "Nunumick.me";
function Dotest () {
Alert (' Hello World ');
}
</script>
<iframe src= "http://www.nunumick.me/lab/x-domain/webkit-test.html" >
</iframe>
2. Sub-page code:
Copy Code code as follows:
<script>
try{
Top.name;
}catch (e) {
Document.domain = ' nunumick.me ';
Top.dotest ();
}
</script>
The purpose of the above code is to attempt to dynamically modify domain to achieve a smooth access while accessing an exception, but the WebKit kernel browser rudely complains rather than throws the intercepted exception, and other browsers are running as scheduled.
Chrome Error message:
It is understood that the use of such a try-catch method to do security feasibility judgment is not only a separate phenomenon, such as Dojo
Copy Code code as follows:
try{
If we can access the IFRAME ' s location
Without a permission denied error
var iframesearch = _getsegment (Iframeloc.href, "?");
Good, the IFRAME is same origin (no thrown exception)
if (document.title!= doctitle) {
Sync title of main window with title of IFRAME.
DocTitle = This.iframe.document.title = Document.title;
}
}catch (e) {
Permission Denied-server cannot be reached.
Ifroffline = true;
Console.error ("Dojo.hash:Error adding history
Entry. Server unreachable. ");
}
Another example of FCKeditor
Copy Code code as follows:
try{
if ((/fcksource=true/i). Test (Window.top.location.search))
sfile = ' fckeditor.original.html ';
}
catch (E) {/* Ignore it. Much probably we are insi
De a FRAME where the "top" was in another domain (security error). */ }
And a lot of netizens ' Feedback: Chrome bug report
None of the above code is applicable in Chrome,safari,opera. Turned over some information, recorded here:
1.HTML5 Security Location
2.webkit Dev Lists
From the WebKit developer's discussion message, they acknowledged the problem but were reluctant to correct it, Holly shit!