file_documentdomain.html 829 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <script type="application/javascript">
  5. function setDomain(domain) {
  6. document.domain = domain;
  7. }
  8. function tryToAccess(otherWin) {
  9. try {
  10. var text = otherWin.document.getElementById('foo').innerHTML;
  11. return /Better Late/.exec(text);
  12. } catch (e) { return false; }
  13. }
  14. var gRef = null;
  15. function storeReference(otherWin) {
  16. gRef = otherWin.document.getElementById('foo');
  17. }
  18. function tryToAccessStored() {
  19. try {
  20. return /Better Late/.exec(gRef.innerHTML);
  21. } catch (e) { return false; }
  22. }
  23. function invokingFunctionThrowsSecurityException(name) {
  24. try {
  25. window[name]();
  26. return false;
  27. } catch (e) { return /insecure|denied/.test(e); }
  28. }
  29. </script>
  30. </head>
  31. <body>
  32. <span id="foo">Better Late than Never</span>
  33. </body>
  34. </html>