fix: open printable Study Load via blob URL to avoid cross-origin document error
This commit is contained in:
+8
-3
@@ -156,13 +156,18 @@
|
||||
if (!included.length) throw new Error('No enrolled courses found.');
|
||||
const totalUnits = ISMIStools.sumUnits(included);
|
||||
const html = ISMIStools.buildStudyLoadHtml({ header, courses: included, totalUnits });
|
||||
const win = window.open('', '_blank');
|
||||
const blob = new Blob([html], { type: 'text/html' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const win = window.open(url, '_blank');
|
||||
if (!win) {
|
||||
URL.revokeObjectURL(url);
|
||||
showToast('Popup blocked — allow popups for this site, then try again.', true);
|
||||
return;
|
||||
}
|
||||
win.document.write(html);
|
||||
win.document.close();
|
||||
// The blob document runs its own onload → window.print(). Never touch
|
||||
// win.document here: if the new tab navigates cross-origin, accessing it
|
||||
// throws "Permission denied".
|
||||
setTimeout(() => URL.revokeObjectURL(url), 60000);
|
||||
showToast('Opened printable Study Load.');
|
||||
} catch (err) {
|
||||
showToast('Error: ' + ((err && err.message) || err), true);
|
||||
|
||||
Reference in New Issue
Block a user