How To Set Title In Window Popup When URL Points To A PDF File?
In javascript I create a URL which points to a PDF and open a new window. The window title contains the URL which I would like to hide from the user. I tried the following suggest
Solution 1:
You cannot hide the URL that way, but you can create a popup window with custom content and embed the PDF file inside, instead of directly linking to the PDF file.
Like:
<html>
<head>
<title>This is your title</title>
</head>
<body>
<iframe src="your_pdf_file_link"></iframe>
</body>
</html>
But if the client don't have a PDF plugin, they will always receive a "Save As" dialog.
Solution 2:
Use instead window.open onclick of hyperlink. In window.open pass the url of your pdf. this way you would be control the window by setting its tittle, it size etc etc
Solution 3:
Maybe the new window could be an HTML page and you could display the PDF in an iframe? Pass all the information you need to the new window in the query string.
Solution 4:
Thanks for the iframe tip. This is what worked for me:
<script type="text/javascript">
var birtwin = null;
var birturl = null;
function birt(report, params) {
var url = "http://myserver/webapps/birt/run?__report=Report/" + report + "&__lc=<%= user.getLocale() %>&__format=pdf&__runtime=<%= LoginServlet.isTest() ? "test" : "prod"%>&";
var chk = document.getElementById('chkPageBreak');
if(chk && chk.checked) url += "PageBreak=true&";
if(params) {
params = params.replace('%MMSFAIRID%', '<%= user.getFair().getFairId() %>');
params = params.replace('%LANGUAGE%', '<%= user.getLocale().getLanguage() %>');
}
url += params;
birturl = url;
birtwin = window.open('','MMSBIRT', 'menubar=0,location=0,toolbar=0,resizable=1,status=1,scrollbars=1');
checkbirt(); // start checking
}
function checkbirt() {
if(birtwin.document) {
birtwin.document.write('<html><head><title>Bericht / Report</title></head><body height="100%" width="100%"><iframe src="' + birturl + '" height="100%" width="100%"></iframe></body></html>');
} else {
// if not loaded yet
setTimeout(checkbirt, 10); // check in another 10ms
}
}
Post a Comment for "How To Set Title In Window Popup When URL Points To A PDF File?"