ファイル置き場+のファイルを自動的にダウンロードさせる方法

  • 更新

ファイル置き場+のダウンロードURLをクリックしなくても、ページにアクセスしただけでダウンロードさせたい場合、サイトのページを作成いただき、その1ページのソースのbody内にファイル置き場+の差込記号を設置しておきます。
さらにページにJavascriptを設置しておき、ページが読み込みされた際にそのURLにアクセスするよう記述しておくと、URLにアクセスしただけで自動的にダウンロードする形と近い動きになります。

以下は、サンプルソースです。

<html lang="ja"> <head> ##html:content_type## <meta http-equiv="Content-Style-Type" content="text/css" /> </head> <body style="margin:0; text-align:center;"> <header style="background: #000066; color:white;padding: 40px 0;"> <h1 style="margin:0;">******** DL</h1> </header> <main style="min-height: calc(100vh - 316px);"> <div> <p>ダウンロードが始まらない場合は下記リンクをクリックしてください。<br /></p> ##file:3## </div> </main> <footer> <small>©Tricorn Corporation</small> </footer> <script> window.onload = function(){ var link = document.getElementsByTagName("a"); var url = link[0].getAttribute("href"); location.href= url; } </script> </body> </html>