old-moya.component.ts
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
import {Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy} from "@angular/common";
@Component({
selector: 'app-old-moya',
providers: [Location, {provide: LocationStrategy, useClass: PathLocationStrategy}],
templateUrl: './old-moya.component.html',
styleUrls: ['./old-moya.component.css']
})
export class OldMoyaComponent implements OnInit {
frameUrl: String = "/MoyaWeb/";
@ViewChild('iframe') iframe: any;
height: string = "1000px";
constructor(private location: Location) {
let tmpUrl = this.location.path(true).split("#",2);
if(tmpUrl.length > 1) {
this.frameUrl = "/MoyaWeb/" + tmpUrl[1];
}
}
ngOnInit() {
}
changeUrl() {
let tmpUrl = this.iframe.nativeElement.contentWindow.location.href.split("/MoyaWeb/",2);
if(tmpUrl.length > 1) {
this.location.replaceState(this.location.path(false) + "#" + tmpUrl[1]);
}
this.height = this.iframe.nativeElement.contentWindow.document.body.scrollHeight + "px";
}
}