我在index.html
中有以下代码:
<a data-ajax="false" rel="external" href="../Info/BasicDefinition.pdf"
data-theme="c" data-iconpos="top" data-icon="arrow-d" data-role="button">Structure</a>
但我收到404错误 - 点击structure
链接后找不到文件。我必须改变什么?我想从浏览器打开.pdf文件。
我的文件结构(MPSR - 我网站的根文件夹)
-MPSR
-----index.html
-Info
-----BasicDefinition.pdf
答案 0 :(得分:1)
无Ajax链接
指向其他域或具有rel =“external”,data-ajax =“false”或目标属性的链接将不会加载Ajax。相反,这些链接将导致整页刷新而没有动画过渡。两个属性(rel =“external”和data-ajax =“false”)具有相同的效果,但是在链接到另一个站点或域时应使用不同的语义:rel =“external”,而data-ajax =“ false“对于简单地选择域中的页面通过Ajax加载非常有用。由于安全性限制,框架始终选择从Ajax行为中链接到外部域。
来源:http://jquerymobile.com/demos/1.0.1/docs/pages/page-links.html
因此,您可以从标记中删除rel="external"
,它应该有效。
我不能在jsFiddle上发布这个,因为它不起作用,但我在这里测试过它运行良好:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.css" />
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.1/jquery.mobile-1.2.1.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Page Title</h1>
</div>
<div data-role="content">
<p>
<a data-ajax="false" href="../info/test.txt" data-iconpos="top" data-icon="arrow-d" data-role="button">Link</a>
</p>
</div>
<div data-role="footer">
<h4>Page Footer</h4>
</div>
</div>
</body>
</html>
文件夹结构:
\test
\info
\test.txt
\root
\index.html