I need to have a way to create a link that opens a specific word document.
How can I write a javascript function to do that?
thanks
| SitePoint Sponsor |
I need to have a way to create a link that opens a specific word document.
How can I write a javascript function to do that?
thanks





why don't you just link directly to the document itself?
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes





why don't you just link directly to the document itself?
You are never going to be able to control the way a document is handled on a users computer.
Adobe Certified Coldfusion MX 7 Developer
Adobe Certified Advanced Coldfusion MX Developer
My Blog (new) | My Family | My Freelance | My Recipes





JavaScript doesn't have the capacity to open external applications (and besides why use JScript when you can use HTML instead?)
As Creole said, you just simply link to the word document. However, due to everyone's different computer software configurations you won't be able to control how the word document is opened.


All what's been said has been correct. However, you can open up an application (although it asks the user for permission and alerts them because of the script needed for it). Take a look to see what I mean:
<script language="Javascript">
<!--//
function runIt(prog) {
if (document.all) {
var wsh=new ActiveXObject("WScript.Shell");
if (wsh) {wsh.Run(prog)}
}
else if ((navigator.appName.indexOf("Netscape")!=-1) && navigator.javaEnabled()) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalExecAccess");
java.lang.Runtime.getRuntime().exec(prog)
}
}
//-->
</script>
For example, to open Notepad:
runIt("notepad")
MSN Messenger:
runIt("msmsgs")
I don't know and couldn't figure out how to open MS Word, though, but why do you need ms word in the regular window and why not just in a browser window?
aDog![]()
Moderator at www.javascriptcity.com/forums/
You can see the thread here:
http://forums.devshed.com/showthread...2590&forumid=3
Which I assume was posted by the same person. Opening Word with a file loaded into it was also discussed there.


Thanx jkd!!
aDog![]()
Moderator at www.javascriptcity.com/forums/
Bookmarks