测试了一下
1.doc文档在同一个目录下面
test.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript" type="text/javascript" src="test.php"></script>
<script language="javascript" type="text/javascript">
function openDoc()
{
var openDocObj = new ActiveXObject("SharePoint.OpenDocuments.1");
openDocObj.ViewDocument(filepath);
}
</script>
</HEAD> <BODY >
<input type="button" value="打开Word" onclick="openDoc()" />
</BODY>
</HTML>test.php
<?php
//header("content-Type: text/html; charset=utf-8");
function getcwdOL(){
$total = $_SERVER[PHP_SELF];
$file = explode("/", $total);
$file = $file[sizeof($file)-1];
return substr($total, 0, strlen($total)-strlen($file)-1);
}
$currenturl= getcwdOL();//取得当前目录
$currenetFile="'"."http://".$_SERVER['SERVER_NAME'].":".$_SERVER["SERVER_PORT"].$currenturl."/1.doc'";
echo "var filepath=".$currenetFile.";alert(escape(filepath));";
//echo $currenturl;
?>
1.doc文档在同一个目录下面
test.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language="javascript" type="text/javascript" src="test.php"></script>
<script language="javascript" type="text/javascript">
function openDoc()
{
var openDocObj = new ActiveXObject("SharePoint.OpenDocuments.1");
openDocObj.ViewDocument(filepath);
}
</script>
</HEAD> <BODY >
<input type="button" value="打开Word" onclick="openDoc()" />
</BODY>
</HTML>test.php
<?php
//header("content-Type: text/html; charset=utf-8");
function getcwdOL(){
$total = $_SERVER[PHP_SELF];
$file = explode("/", $total);
$file = $file[sizeof($file)-1];
return substr($total, 0, strlen($total)-strlen($file)-1);
}
$currenturl= getcwdOL();//取得当前目录
$currenetFile="'"."http://".$_SERVER['SERVER_NAME'].":".$_SERVER["SERVER_PORT"].$currenturl."/1.doc'";
echo "var filepath=".$currenetFile.";alert(escape(filepath));";
//echo $currenturl;
?>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货