我的html中有一个链接:
<a href="/UserManual/Manual.pdf" target="iframe_a" id="framefile" class="framefile">Manual</a>
运行页面并单击链接时,发生错误:
找不到404
我检查了位置。正确,文件在那里。 当我尝试检查元素时。我的代码如下:
<a href="/UserManual/Manual.pdfManual" target="iframe_a" id="framefile" class="framefile">Manual</a>
似乎链接文本附加在href
属性中。似乎是什么问题?
编辑: 下面是我的脚本:
<script>
$("a.framefile").each(function () {
var $this = $(this);
var _href = $this.attr("href");
$this.attr("href", _href + $this.text());
});
</script>
答案 0 :(得分:1)
此代码:
$this.attr("href", _href + $this.text());
完全按照您的描述将链接的文本添加到其href
中。
删除该代码(实际上是整个<script>
)。按照书面规定,您的JavaScript只能用于一个明显的目的-断开链接。