我是一个使用XHTML模板创建电子商务网站的新手。我想在某些项目下添加免责声明,但不是全部。为避免在每个条目下键入免责声明(并且如果免责声明发生变化,将来避免出现问题),我希望使用javascript创建一个副本块,当我指向它时,会添加免责声明。我已经成功完成了(yah!),但是在免责声明中是指向pdf的链接。当我使用html链接到PDF时,它失败。我知道这可能是因为我没有正确的语法,因为HTML是JavaScript代码中的“内部”。有人可以帮忙吗?如何在JavaScript中创建指向PDF的链接?
这是我有:
//<![CDATA[
function openPDF(file)
{
window.open (file, 'resizable,scrollbars');
}
//]]>
</script>
<script type="text/javascript">
//<![CDATA[
onload=function()
{
var txt=document.getElementById("myDiv")
txt.innerHTML="Photos do not represent actual size. Refer to measurements for sizing.
Measurements are approximate. Colors shown may differ depending on your computer
settings. Colors described are subjective and colors may vary from piece to piece,
depending on the natural properties of the stones. To learn more, see our <a href="#"
onClick="openPDF('www.shop.site.com/media/JewelryGuide.pdf')">Jewelry Guide</a>.";
}
//]]>
</script>
下面是我用它调用的代码:
<div id="myDiv"></div>`