windows 从 IE 打开 Word 文档
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2728307/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Opening Word Document from IE
提问by Nalum
I'm opening a word document through IE on a local network, it opens up fine but if a document is password protected then it should prompt for the password which it doesn't.
我在本地网络上通过 IE 打开一个 word 文档,它打开得很好,但如果一个文档受密码保护,那么它应该提示输入密码,而它没有。
Is there something that I should be doing to get the password prompt?
我应该做些什么来获得密码提示?
The way I'm opening the document is by a link on a web page e.g.
我打开文档的方式是通过网页上的链接,例如
<a href="\path\to\file.doc">Document</a>
采纳答案by Nalum
I've got what I want working using the following javascript/jQuery. jQuery is not required, I used it as I already have it as part of the project.
我已经使用以下 javascript/jQuery 完成了我想要的工作。jQuery 不是必需的,我使用它是因为我已经将它作为项目的一部分。
$('a.openDoc').live('click',function(){
var file = $(this).attr('href');
// This is what does the work.
try
{
try
{
// get Word Active-X Object if Word is open.
var word = GetObject('',"Word.Application");
}
catch(e)
{
// create new Word Active-X Object.
var word = new ActiveXObject("Word.Application");
}
word.Visible = true; // Make sure Word is visible.
word.Documents.Open(file); // Open the file you want.
}
catch(e)
{
alert(e.description);
}
// End work.
return false;
});
回答by Pedery
In case you are ok with having the document open in Word itself (and notin IE), maybe this will point you in the right direction:
如果您可以在 Word 本身(而不是IE)中打开文档,这可能会为您指明正确的方向:
http://www.velocityreviews.com/forums/t109523-open-word-doc-in-word-not-in-browser.html
http://www.velocityreviews.com/forums/t109523-open-word-doc-in-word-not-in-browser.html