I have a servlet that generates a PDF and the output goes to a new browser window. I am attempting to replace the title of that new window using the updateTitle() function below. However, when I try to assign the report name (repName) to the window instance, IE11 throws a "Permission denied" error. Any ideas?
function showReport(url, repName){
var repWin = window.open(url);
updateTitle(repWin, repName)
}
function updateTitle(repWin, repName) {
setTimeout(function() {
repWin.document.title = repName; //IE11 console throws PERMISSION DENIED here
}, 3000);
}
You will need to use something like postMessage .
On your original window:
function showReport(url, repName) {
var repWin = window.open(url);
repWin.postMessage('setTitle:' + repName, '*');
}
On the repWin
:
function updateTitle(message) {
var m = message.data.split(':'),
eventType = m[0],
data = m[1];
if (message.origin === 'YOUR_URL_HERE' && eventType === 'setTitle' ) {
repWin.document.title = data;
}
}
window.addEventListener("message", updateTitle, false);
Note: This will obviously only work if you can modify the source for the window you are opening.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.