Files
encoach_frontend/src/utils/popout.ts

21 lines
721 B
TypeScript

import { NextRouter } from "next/router";
const openDetachedTab = (uri: string, router: NextRouter, name = 'ExamPreview', width = 1000, height = 600) => {
const left = (window.screen.width - width) / 2;
const top = (window.screen.height - height) / 2;
const features = `width=${width},height=${height},left=${left},top=${top},resizable=yes,scrollbars=yes,status=yes`;
const url = router.basePath + `/${uri}`;
const newWindow = window.open(url, name, features);
if (newWindow) {
newWindow.focus();
} else {
alert('Pop-up blocker may have prevented opening the new window. Please check your browser settings.');
}
return newWindow;
}
export default openDetachedTab;