File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change 1+ export class WindowLocationService {
2+
3+ public static changeLocation ( destination : string ) : void {
4+ window . location . assign ( destination ) ;
5+ }
6+
7+ public static changeLocationAfterPageLoad ( destination : string ) : void {
8+ // Wait for resources to load before redirect. Without this Safari would fail
9+ // to load/activate resources, like fonts.
10+ const waitForPageLoad = ( ) => {
11+ if ( document . readyState === 'complete' ) {
12+ WindowLocationService . changeLocation ( destination ) ;
13+ } else {
14+ setTimeout ( waitForPageLoad , 500 ) ;
15+ }
16+ } ;
17+ waitForPageLoad ( ) ;
18+ }
19+
20+ public static getHashQueryString ( ) : string {
21+ return window . location . hash . substring ( 1 ) ;
22+ }
23+
24+ public static getLocationOrigin ( ) : string {
25+ if ( window . location . origin ) {
26+ return window . location . origin ;
27+ }
28+ // IE11 fix, when window.location.origin is undefined
29+ let locationOrigin = `${ window . location . protocol } //${ window . location . hostname } ` ;
30+ locationOrigin += window . location . port ? ':' + window . location . port : '' ;
31+ return locationOrigin ;
32+ }
33+ }
You can’t perform that action at this time.
0 commit comments