// wwwroot/js/childWindow.js
function openWindowWithZoomAndFocus(url) {
const childWindow = window.open(url, "_blank");
// 자식 창이 열렸는지 확인한 후 포커스와 줌을 설정합니다.
if (childWindow) {
childWindow.focus(); // 포커스를 자식 창에 맞춥니다.
childWindow.onload = () => {
childWindow.document.body.style.zoom = "80%";
};
}
}
builder.Services.AddScoped<IJSRuntime, JSRuntime>();
@inject IJSRuntime JS
<button @onclick="OpenChildWindowWithZoomAndFocus">Open Child Window</button>
@code {
private async Task OpenChildWindowWithZoomAndFocus()
{
await JS.InvokeVoidAsync("openWindowWithZoomAndFocus", "https://example.com");
}
}
728x90
댓글