This is my try, were it opened on newtab, But its always showing test pdf as title
function titlepath(path,name){
alert(path);
alert(name);
document.title = name;
window.open(path, '_blank');
}
This is my try, were it opened on newtab, But its always showing test pdf as title
function titlepath(path,name){
alert(path);
alert(name);
document.title = name;
window.open(path, '_blank');
}
document.title
refers to the window you're in now, not the one you're opening, Even then I'm not sure it'll work, since a PDF is not a HTML document, so you can't set its title. Javascript can only affect HTML documents. The browser is just displaying a file, so it'll use the name of the file
– ADyson
Commented
Jun 8, 2018 at 11:42
<iframe>
– user5734311
Commented
Jun 8, 2018 at 11:42
This solution works for me. Question: How to change the title of pdf in newly opened tab
function titlepath(path,name){
//In this path defined as your pdf url and name (your pdf name)
var prntWin = window.open();
prntWin.document.write("<html><head><title>"+name+"</title></head><body>"
+ '<embed width="100%" height="100%" name="plugin" src="'+ path+ '" '
+ 'type="application/pdf" internalinstanceid="21"></body></html>');
prntWin.document.close();
}