If domain is same then you can change the title of new window
<script type="text/javascript">
var w = window.open('http://localhost:4885/UMS2/Default.aspx');
w.document.title = 'testing';
</script>
Answer from Muhammad Shoaib on Stack OverflowIf domain is same then you can change the title of new window
<script type="text/javascript">
var w = window.open('http://localhost:4885/UMS2/Default.aspx');
w.document.title = 'testing';
</script>
Here is my solution, please check this out:
var myWindow = window.open('<myfile>.pdf','my window','resizable,scrollbars');
myWindow.document.write('<title>My PDF File Title</title>');
Hope I could help.
Hi all, new to the concept of bookmarklets. I have a little bit of JS knowledge but not great. I'm trying to get this example bookmark to open with a custom window title but I can't quite figure out how. Any pointers? This is exactly what I'm using as my bookmark which is opening the window as I want it; I just need to change the window title so I can set it up in a DisplayFusion window position profile.
I might have achieved what I need using this extension, but wouldn't hurt to learn how this can be done from JS. https://chromewebstore.google.com/detail/change-page-title/ebbfpplpmnoblfmdkbicmakmbbjijdpg
javascript:void(window.open('https://player.twitch.tv/?channel=shroud&enableExtensions=true&muted=true&parent=twitch.tv&player=popout&volume=0%27,%27popout_chat%27,%27width=800,height=400%27))
Since popup.onload does not seem to work, here is a workaround: https://jsfiddle.net/mta5x469/.
var win = window.open('', 'foo', ''); // open popup
function check() {
if(win.document) { // if loaded
win.document.title = "test"; // set title
} else { // if not loaded yet
setTimeout(check, 10); // check in another 10ms
}
}
check(); // start checking
I was having problems with the accepted answer until I realized that if you open an existing, slow page that already has a <title> the browser will 1) set your title, then 2) once the document fully loads it will (re)set the popup title with the "normal" value.
So, introducing a reasonable delay (function openPopupWithTitle):
var overridePopupTitle = function(popup, title, delayFinal, delayRepeat) {
// https://stackoverflow.com/a/7501545/1037948
// delay writing the title until after it's fully loaded,
// because the webpage's actual title may take some time to appear
if(popup.document) setTimeout(function() { popup.document.title = title; }, delayFinal || 1000);
else setTimeout(function() { overridePopupTitle(popup, title); }, delayRepeat || 100);
}
var openPopupWithTitle = function(url, title, settings, delay) {
var win = window.open(url, title, settings);
overridePopupTitle(win, title, delay);
return win;
}
Then put it to onload event:
win.onload = function() { this.document.title = "your new title"; }
Try this
var win = null;
function NewWindow(wizpage, wizname, w, h, scroll){
LeftPosition = (screen.width) ? (screen.width-w)-8 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings = 'height=' + h + ',width=' + w + ',top= 100,' + TopPosition + ',left=' + LeftPosition + ',scrollbars=' + scroll + ',resizable';
win = window.open(wizpage, wizname, settings);
win.document.title = "your new title";
}
Try this:
....
var newWindow = window.open(newdata, "_blank");
newWindow.document.title = "Some title";
....
EDIT:
Another way to do this might be to send an iframe to a new window instead of opening it directly with the base64 string.
So something like:
var newWindow = window.open();
newWindow.document.write('<iframe src="data:application/pdf;base64,' + (strData) + '" frameborder="0" allowfullscreen></iframe>');
newWindow.document.title = "Your Title Here";
This worked for me.
var newWindow = window.open(newdata, "_blank");
setTimeout(function(){ newWindow.document.title = 'my new title'; }, 1000);