| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org\tR/xhtml1/DTD/xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <title>iFrame Test</title> |
| <script> |
| function run() |
| { |
| window.frames['test1'].document.open("text/html","replace"); |
| window.frames['test1'].document.close(); |
| |
| var src = "<html>\n<head>\n<script>\nfunction fill()\n{\n document.getElementById(\"domain\").innerHTML = document.domain;\n document.getElementById(\"URL\").innerHTML = document.URL;\n document.getElementById(\"wlh\").innerHTML = window.location.href;\n document.getElementById(\"plh\").innerHTML = parent.location.href;\n}\n<\/script>\n<\/head>\n<body onload=\"fill();\">\nThis iframe's src was set with document.write.\n<br><br>\ndocument.domain: <span id=\"domain\"><\/span>\n<br><br>\ndocument.URL: <span id=\"URL\"><\/span>\n<br><br>\nwindow.location.href: <span id=\"wlh\"><\/span>\n<br><br>\nparent.location.href: <span id=\"plh\"><\/span>\n<\/body>\n<\/html>\n"; |
| window.frames['test2'].document.open("text/html","replace"); |
| window.frames['test2'].document.write(src); |
| window.frames['test2'].document.close(); |
| |
| var oSpan1 = document.getElementById("result1"); |
| var pass = true; |
| var str = ""; |
| if (window.frames['test1'].document.domain != document.domain) { |
| pass = false; |
| str = "document.domain is " + window.frames['test1'].document.domain + " but should be " + document.domain + "<br>"; |
| } |
| |
| if (window.frames['test1'].document.URL != document.URL) { |
| pass = false; |
| str += "document.URL is " + window.frames['test1'].document.URL + " but should be " + document.URL + "<br>"; |
| } |
| |
| if (window.frames['test1'].window.location.href != window.location.href) { |
| pass = false; |
| str += "window.location.href is " + window.frames['test1'].window.location.href + " but should be " + window.location.href + "<br>"; |
| } |
| |
| if (window.frames['test1'].parent.location.href != parent.location.href) { |
| pass = false; |
| str += "parent.location.href is " + window.frames['test1'].parent.location.href + " but should be " + parent.location.href + "<br>"; |
| } |
| |
| if (pass) |
| { |
| oSpan1.setAttribute("style", "color: green;"); |
| oSpan1.innerHTML = "PASS"; |
| } |
| else |
| { |
| oSpan1.setAttribute("style", "color: red;"); |
| oSpan1.innerHTML = "FAIL<br>" + str; |
| } |
| |
| var oSpan2 = document.getElementById("result2"); |
| pass = true; |
| str = ""; |
| if (window.frames['test2'].document.domain != document.domain) { |
| pass = false; |
| str = "document.domain is " + window.frames['test2'].document.domain + " but should be " + document.domain + "<br>"; |
| } |
| |
| if (window.frames['test2'].document.URL != document.URL) { |
| pass = false; |
| str += "document.URL is " + window.frames['test2'].document.URL + " but should be " + document.URL + "<br>"; |
| } |
| |
| if (window.frames['test2'].window.location.href != window.location.href) { |
| pass = false; |
| str += "window.location.href is " + window.frames['test2'].window.location.href + " but should be " + window.location.href + "<br>"; |
| } |
| |
| if (window.frames['test2'].parent.location.href != parent.location.href) { |
| pass = false; |
| str += "parent.location.href is " + window.frames['test2'].parent.location.href + " but should be " + parent.location.href + "<br>"; |
| } |
| |
| if (pass) |
| { |
| oSpan2.setAttribute("style", "color: green;"); |
| oSpan2.innerHTML = "PASS"; |
| } |
| else |
| { |
| oSpan2.setAttribute("style", "color: red;"); |
| oSpan2.innerHTML = "FAIL<br>" + str; |
| } |
| |
| if (window.testRunner) |
| testRunner.dumpAsText(); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="run();"> |
| <iframe name="test1" style="border: 1px solid black;"></iframe><span id="result1"></span><br> |
| <iframe name="test2" style="width: 500px; height: 200px; border: 1px solid black;"></iframe><span id="result2"></span><br> |
| </body> |
| </html> |