<a href> --> new window

Hi Friend

I question how to open a document in a new windown when clicked on hiper link.

example <A HREF="http://loaclhost/abc/process.doc" target="_blank">click here</a>

this shiuld open in a new window. But I have a problem.
when I click the link it is giving popup to open or save.
I dont want to get open or save. I want Word Document to open in new browser window.

How can I do that. what functionality I need to add.

If possible please change the example code and help me out.

Who is Participating?
Hi basirana,

You cannot control what the browser of another person will react like to your document. Some people will have the option turned off to open known document types in a browser window, although by default this is turned on in Internet Explorer. So there's really not that much you can do about it. The way you do it right now, using a target="_blank", is the proper way to open a Word document in the browser with the default options of Internet Explorer. If a user changed his/her settings, you cannot change that back for them.

That's up to the browser.  My browser, for instance, will never display a Word document inline; it will always ask me to save or open it.  Even working in an MSIE-only environment, I recommend against relying on behavior that opens Word documents inline.
basiranaAuthor Commented:
Bcoz I have seen docs openning in the web browser. How can we do that.
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

This Microsoft KB article ( http://support.microsoft.com/kb/162059 ) describes how to UNDO what you want, but that's also enough information to be able to do it.

* From Windows Explorer (i.e. any folder on your computer) Click Tools > Folder Options
* Click the "File Types" tab.
* Find "DOC" in the list of file types, and click the "Advanced" button down at the bottom
* Check the "Browse in Same Window" box.
I should add: I do not personally know of an extension that will allow this for Firefox, Opera, et cetera, though it's entirely possible someone has crafted one.

Most people want the opposite behavior (getting files to open in the appropriate program instead of in the browser), so the trend in available information is gonna be away from what you're trying to do.
basiranaAuthor Commented:
Thats true... but the business requirement is I need to open in new browser window. insted of open or save.
is there anyway we can do it in javascript.

That's what the target="_blank" does.

The Windows option saying "same window" is just Microsoft talking about the browser window vs. the application window.
basiranaAuthor Commented:
I found a sample code. that say target="_blank"
Dennis MaederCommented:
Is this what you want? A mime content-type declaration.
<A HREF="http://loaclhost/abc/process.doc" target="_blank" type='application/msword'>click here</a>

If you absolutely cannot contend with the open/save prompt, then one option could be to have a script running on the server that will output a Word document as HTML, and display the HTML instead.  Of course this would assume that you only wanted the document presented for reading, not for editing.  If you need them to open the document for editing in Word, there really is no way around that prompt, AFAIK.
Create a second html page with source:

<embed src="http://localhost/abc/process.doc" width="100%" height="100%"></embed>

Be aware that this will only work in internet explorer on windows with ms office installed.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.