以下のコードで問題が発生しています。
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 の値と連結し、それを on click にフィードすることです。助けてください 。
実際の要件は、場所を動的に生成する必要があることです。SO 外部 JS 関数にはパスの一部が含まれ、内部 JS 関数には残りの . 両方を連結してそのPDFを開きたいだけです。したがって、myFunction は次のように返されます: //abc/xyz そして、HTML に文字列が含まれているので、それらをマージする必要があります: //abc/xyz/l.pdf この pdf を開きたいだけです