我创建了一个按钮,允许用户下载.apk文件,该文件适用于除Firefox以外的大多数浏览器。
为什么按钮在Firefox中不起作用,其他链接工作正常!
<?php
$server = $_SERVER['SERVER_NAME'];
$page = $server . '/web/text';
$appUrl = $server . '/android/Application.apk';
header("Content-Type: application/xhtml+xml");
echo "<?xml version=\"1.0\"?>";
?><!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Title</title>
</head>
<body>
<?php echo "<a href='http://$page'>This Works Fine</a>"; ?>.
<br />
<br />
<button type="button"><?php echo "<a href='http://$appUrl'>Download</a>"; ?></button>
</p>
</body>
</html>
答案 0 :(得分:0)
我认为这是您正在寻找的,简单且与每个(普通)浏览器兼容:
<button id="download-button" type="button">Download</button>
$('#download-button').click(function(e) {
e.preventDefault();
window.location.href = "www.yourdownloadurl.com";
});
答案 1 :(得分:0)
原来Firefox比其他浏览器更严格:
不应在按钮元素内定义锚点,Chrome等允许这样做,但对于Firefox,按钮应该是一种形式。