Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative Javascript to "_blank"

Status
Not open for further replies.

steve100

Technical User
Aug 15, 2002
35
0
0
GB
Hi can anyone help. I have a problem opening new rft documents in different browsers. In Mozilla based browsers an extra blank window opens and the Word application starts up in a new window. In IE the Word application starts up in a new window with no extra blank window. I need the application to start in a new window (but no extra blank window) because when users close their rtf documents they wouldn't expect the whole website to disappear.

Is it possbible to use a piece of javascript to detect whether a browser is Mozilla or IE and either open a new window for IE (which will have no extra blank window) or target the file to open in the same window for Mozilla (which will open the application in a seperate window- again with no extra blank window).

I think the link would look something like <a href=&quot;test.rtf&quot; onclick=&quot;browser()&quot; onkeypress=&quot;browser()()&quot;>rtf document</a>

But I am not sure how to write &quot;browser&quot; function.

Thanks
Steve

 
I dont understand, you are worried about being cross browser compatable, but you are not worried about the fact that maybe if you are lucky 25 percent of regular folks out there have word on their system?

What are you trying to accomplish? If its something for them to edit then just create it into something they can download and open in their program of their choice, instead of trying to just open it. If its something you are just trying to show an the extension doesnt matter than just rename it, or include it in another page in with pre tags.

 
Hi, my response:

1. RTF files should work with any word processor not just Word.
2. We always need to open documents first - some documents may not need to be downloaded, others will.
3. Even if documebnts were downloaded in Mozilla based browser an annoying blank extra window would still appear ). This is irritating and confusing to novice web users and screenredader users.
4. The extension does matter - files need to be rtf for maximum compatibility as you mention only 25% of web users have word.

Thanks
 
Hi, my response:

1. RTF files should work with any word processor not just Word.
2. We always need to open documents first - some documents may not need to be downloaded, others will.
3. Even if documents were downloaded in Mozilla based browser an annoying blank extra window would still appear. This is irritating and confusing to novice web users and screenreader users.
4. The extension does matter - files need to be rtf for maximum compatibility as you mention only 25% of web users have word.

Thanks
 
steve100,

This returned some pretty good results,
will give you good examples:


search--> javascript navigator.appName compatibility

Shout back if this doesn't complete the picture for you.

2b||!2b
 
I don't know about your opening blank window problem, but if you just wanna test for browser type I think you can do this:

if( document.defaultView ) {
//mozilla code
}
else {
//IE code
}

My company only uses IE so I haven't had to develop for any other browsers, so I've not tested that myself but I've seen it posted here before.


-kaht

banghead.gif
 
>> In IE the Word application starts up in a new window with no extra blank window.

That is the same for both &quot;_blank&quot; and &quot;_self&quot;. Word will never replace the Web Browser window; it's a completely seperate entity.

When you launch a &quot;_blank&quot; in MSIE and it's not actually required (i.e. downloading a file), MSIE emmediately closes it again. The same is not true for Mozilla.

End result is, the &quot;_blank&quot; is doing nothing in MSIE but is working as expected in Mozilla.

Unless there are other complications, your solution is to simply delete the &quot;_blank&quot; and nothing else.
 
I don't think that there is anyway to do this from the script. Some of the applications that I have written open an extra blank window when opening a Word or Excel document on certain computers but not others. This seems to be an option that has been set either in Office or IE though I have never been able to find it.
 
Don't jump on me too hard, I found a post over at forums.devshed.com that is similar...

---THIS IS ALL QUOTED. I AM ONLY COPYING. Credit goes to skippythekid ---

---
Stuff this in the top of your code and change as needed.

Response.ContentType = &quot;application/msword&quot;
Response.AddHeader &quot;Content-Disposition&quot;, &quot;attachment;filename=YourFILE.DOC&quot;
---

Okay, I'm back... obviously a little editing (such as .doc to .rtf) is needed

My thought is, couldn't you specify wordpad (for PCs) and is it simpletext(?) for Macs, (I don't know what to do for non-Microvirus OS's) instead of msword and get Microvirus' share and Mac's share, leaving only the advanced linux/unix type folks...

It doesn't look like it opens in a new window, but rather in the program itself... That seems like it would be a simple work around... Maybe have to detect OS or something...

Runs to corner and hides, hoping to avoid the taunts of more skilled people
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top