2
我有一些鏈接,點擊時會顯示PDF文件。當從筆記本電腦查看時,鏈接工作,但當我在任何移動設備上嘗試它時(我試過iPhone6,galaxy s6和華爲p9)鏈接不做任何事情。我可以點擊它,但那是關於它。鏈接不能點擊手機
<a href="http://localhost/mlndemo/sites/default/files/2017-02/voorbeeld_sollicitatiebrief_0.pdf" type="application/pdf; length=420819" title="voorbeeld_sollicitatiebrief.pdf">Bekijk hier de volledige vacature</a>
如果有人可以幫助我這是爲什麼不工作在移動設備上,這將是巨大的:)在此先感謝您的幫助
編輯: 發現這個代碼在使target_blank成爲drupal站點。這似乎工作,因爲它現在在新窗口中打開文件。爲了某人可能需要它,我會在這裏發佈代碼。 這僅適用於Drupal(8)將THEME更改爲您的主題名稱。
/**
* Implements hook_preprocess_HOOK().
*/
function THEME_preprocess_file_link(&$variables) {
// Add target _blank attribute to all file links.
$file = $variables['file'];
$url = file_create_url($file->uri->value);
// Use the description as the link text if available.
if (empty($variables['description'])) {
$link_text = $file->filename->value;
}
else {
$link_text = $variables['description']->__toString();
}
$link = '<a href="'.$url.'" type="'.$file->filemime->value . '" length="' . $file->filesize->value . '" title="' . \Drupal\Component\Utility\Html::escape($file->filename->value) . '" target="_blank">' . \Drupal\Component\Utility\Html::escape($link_text) . '</a>';
$variables['link']->setGeneratedLink($link);
}
有可能沒有內置的支持PDF – mplungjan
http://stackoverflow.com/questions/18564774/how-to-support-pdf-viewing-for-all-mobile-browser – mplungjan
謝謝,將檢查出來! – Blomkfist174