Neighbourhood.omg.lol/Components/ExternalPageComponent.razor

32 lines
903 B
Text
Raw Permalink Normal View History

2024-06-11 00:36:48 +00:00
@inject IJSRuntime JS
@inject State State
@inject RestService api
2024-06-11 00:36:48 +00:00
@if(Html != null) {
<iframe id="@id" frameborder="0" scrolling="no" srcdoc="@Html" onload="() => iframeResize({ license: 'GPLv3' })"></iframe>
}
@code {
[Parameter]
public string Url { get; set; }
[Parameter]
public string id { get; set; }
public MarkupString? Html { get; set; }
2024-06-11 00:36:48 +00:00
protected override async Task OnAfterRenderAsync(bool firstRender) {
if(firstRender){
await Reload();
}
}
public async Task Reload() {
2024-06-24 04:52:45 +00:00
// if (Html == null){
2024-06-11 00:36:48 +00:00
Html = await api.GetHtml(Url);
string? HtmlString = Html?.ToString();
HtmlString = HtmlString?.Replace("</head>", "<base target='_blank'></head>");
HtmlString = HtmlString?.Replace("</body>", "<script src='https://cdn.jsdelivr.net/npm/@iframe-resizer/child'></script></body>");
Html = (MarkupString)HtmlString;
2024-06-24 04:52:45 +00:00
// }
2024-06-11 00:36:48 +00:00
await InvokeAsync(StateHasChanged);
}
}