| | 33 | |
| | 34 | // Automatically detect the correct document.domain (#123). |
| | 35 | (function() |
| | 36 | { |
| | 37 | var d = document.domain ; |
| | 38 | |
| | 39 | while ( true ) |
| | 40 | { |
| | 41 | // Test if we can access a parent property. |
| | 42 | try |
| | 43 | { |
| | 44 | var parentDomain = window.opener.document.domain ; |
| | 45 | |
| | 46 | if ( document.domain != parentDomain ) |
| | 47 | document.domain = parentDomain ; |
| | 48 | break ; |
| | 49 | } |
| | 50 | catch( e ) {} |
| | 51 | |
| | 52 | // Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ... |
| | 53 | d = d.replace( /.*?(?:\.|$)/, '' ) ; |
| | 54 | |
| | 55 | if ( d.length == 0 ) |
| | 56 | break ; // It was not able to detect the domain. |
| | 57 | |
| | 58 | document.domain = d ; |
| | 59 | } |
| | 60 | })(); |