Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 360
  • Last Modified:

How to Set the Browser Title for non-HTML Document?

Is there are a way to set the browser title when putting a non-HTML document (e.g. a PDF or XML doc) in a browser?

The best I can tell, this was at one time possible with an HTTP header but is no longer supported.  I know I can do this by putting the non-HTML document in a frame and putting a title on the enclosing frameset, but this seems rather clunky.

Thanks in advance,

Marc
0
marc_rabil
Asked:
marc_rabil
1 Solution
 
seanpowellCommented:
Here's one solution:

<html>
<head>
<title>My PDF File</title>
<style type="text/css">
<!--
body { margin:0px; padding:0px; overflow:hidden; }
//-->
</style>
</head>
<body>
<embed src="myfile.pdf" width="100%" height="100%">
</body>
</html>
0
 
gam3r_3xtr3m3Commented:
we know framesets are clunky, but that's the only way to do it.

-gam3r
0
 
jarasaCommented:
HI
Can you be more explicit on what you want to do?
I mean, you have a PDF and want to show it on a new page, or just any pdf that could be found on the Internet through your page?
regards
Javier
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
seanpowellCommented:
>>we know framesets are clunky, but that's the only way to do it.
Actually, there's a number of ways to do it without framesets - one example is above...
0
 
JakobACommented:
<!doctype
0
 
marc_rabilAuthor Commented:
jarasa:

We have a web application that puts various document types (eg. PDFs, XML, etc) in a new browser window. Everything works fine, except the new window title is the URL to the document and we want to make it a user friendly name like "Document Window".  The documents are usually not real files but are generated dynamically.  They are served up from our server so we have the opportunity to manipulate the response before the bytes are sent to the window.

Of course, we can first return HTML like a frameset (or an embed tag as suggested by georgemarian) which sets the title and in turns calls the document but I was hoping there was an easier way like to just set an HTTP header or something.

JakobA:

It looks like something is missing from your comment.

Marc
0
 
jarasaCommented:
Hi Marc.

Try to find a javascript library called ByKlein_chromeless.js it will let you put the Title always no matter what you do and in iExplorer lets you cahnge almost all the GUI from the browser so you can even put a PDF icon or whatever. I said try to find it becose is not easy any more, the home page of this guy does not work any longer, if you're not able to find it let me Know and I'll send it to you some how, I know is not able to put emails here but maybe I'll be able to put it some where on the internet and give you the URL.

regards

Javier
0
 
seanpowellCommented:
Well at it's simplest level, "title" is a property of the object "document", so it can be easily accessed (except that it's read-only in NN4...)

One way would just be to modify the document title with some simple javascript, either in the head or the body section - although the former is probably preferable

<html>
<head>
<script language="javascript" type="text/javascript">
<!--
document.title = "My PDF Document";
//-->
</script>
</head>
<body>
PDF File outputs here...
</body>
</html>
0
 
jarasaCommented:
Hi georgemarian.
I think that the problem of marc is that he does not control the output of the PDF becose is gerated dinamically, so he just sent the content to the outputStream and the browser opens it itself.
Javier
 
0
 
seanpowellCommented:
Hmmm...although he should still be able to control how the new window is generated, no? Or am I missing something...
0
 
jarasaCommented:
Well if you open the new window with a title and call a servlet wich generates a pdf and opens you a download window when you say open it instead of save as file I think it changes the title and puts the temporal name of it.
I believe I had that problem but solved by unassinnig the PDF from the browser so it always opens the Acrobat and don't display it on the browser. but I think the javascript I said it does not change the title.
Javier
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now