我有在下面的代码问题,调用1个外部JavaScript函数从另一个
MyConfig.js(这是一个外部js文件)
function myFunction()
{
var tfile = "file://";
// Server Location(should be changed at the time of deployment)
var location = "inhyds149";
// Document folder location. The user documents will be pulled from here.
var staticpath = "/Documents/pdfs/";
var n=tfile.concat(location,staticpath);
return n;
}
我的HTML内容::
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Adobe RoboHelp 10" />
<title>Third</title>
<link rel="StyleSheet" href="default.css" type="text/css" />
<script src="D:\Test\MyConfig.js" type="text/javascript"/>
</head>
<body>
<script>
function myFinal()
{
var tfile1 = myFunction();
var location1 = "Holidays 2013.pdf";
// Document folder location. The user documents will be pulled from here.
var n1=tfile1.concat(location);
return n1;
}
</script>
<h1>Third</h1>
<p>Dynamically hyperlink pdf to <span style="font-weight: bold;">'welcome'</span>
keyword</p>
<p> </p>
<p><a id="Link" onclick="myFinal()" target="_blank">Welcome</a></p>
</body>
</html>
我的要求是将我从外部js文件获得的结果与位于我的js文件中的location1中的值连接起来,并在点击时提供给它。请帮忙 。
其实需求是我需要动态生成一个位置。所以外部JS函数将包含部分路径,并且内部JS函数将包含剩余的部分。我只想连接它们并打开PDF。所以这将是myFunction将返回说:// abc/xyz我将有一个字符串在我的HTML和我必须合并他们说://abc/xyz/l.pdf我只是想打开此pdf
你想用你的函数'myFinal()返回的值做什么?' –
其实myFinal应该返回字符串值,它将是pdf的位置,我只想打开PDF – user2866242
并点击你想要的打开pdf的权利? –