R
Reactiflux

snowberb – 11-12 Sep 19

snowberb – 11-12 Sep 19

S⛄Snowberb⛄9/19/2023
How can I change the PDF title after using an iframe to display a base64 pdf? I tried with:
const newTab = window.open('');

if (newTab) {
newTab.document.title = documentName;
newTab?.document.write(
`<iframe title="${documentName}" width='100%' height='100%' src='data:application/pdf;base64,${encodeURI(
base64,
)}'></iframe>`,
);
}
const newTab = window.open('');

if (newTab) {
newTab.document.title = documentName;
newTab?.document.write(
`<iframe title="${documentName}" width='100%' height='100%' src='data:application/pdf;base64,${encodeURI(
base64,
)}'></iframe>`,
);
}
No description
UUUnknown User9/19/2023
Message Not Public
Sign In & Join Server To View
S⛄Snowberb⛄9/19/2023
Tried like this and didnt work:
const newTab = window.open('');

if (newTab) {
newTab.onload = () => {
newTab.document.title = documentName;
};
newTab?.document.write(
`<iframe title="${documentName}" width='100%' height='100%' src='data:application/pdf;base64,${encodeURI(
base64,
)}'></iframe>`,
);
}
const newTab = window.open('');

if (newTab) {
newTab.onload = () => {
newTab.document.title = documentName;
};
newTab?.document.write(
`<iframe title="${documentName}" width='100%' height='100%' src='data:application/pdf;base64,${encodeURI(
base64,
)}'></iframe>`,
);
}
S⛄Snowberb⛄9/19/2023
Btw im not trying to change the navigator tab name, I want to change the PDF file name
No description
S⛄Snowberb⛄9/19/2023
No description
SScriptyChris9/19/2023
You want to change frame's title attribute? Try querying the iframe element and then just change its title attribute Something like :
newTab.document.querySelector(`[title="${documentTitle}"]`).title = 'new title' ;
newTab.document.querySelector(`[title="${documentTitle}"]`).title = 'new title' ;
S⛄Snowberb⛄9/20/2023
no, the file name not the tab name I literally sent a screenshot
SScriptyChris9/20/2023
On what DOM element that file name is set? You should be able to modify, but i wonder why do you want to change the title instead of setting it already to the correct one? You could also try changing the title in the base64 - decode it, change title, encode and put back into the iframe
UUUnknown User9/21/2023
Message Not Public
Sign In & Join Server To View

Looking for more? Join the community!

R
Reactiflux

snowberb – 11-12 Sep 19

Join Server