簡體   English   中英

加載URL + JavaScript操作

[英]Load URL + JavaScript action

我試圖讓我的用戶從我的網站上的bungie.net下載“地圖”。

示例圖:

http://www.bungie.net/Online/Halo3UserContentDetails.aspx?h3fileid=31604914

鏈接用戶需要點擊下載地圖:

<a id="ctl00_mainContent_xboxDownloadButton" href="javascript:__doPostBack('ctl00$mainContent$xboxDownloadButton','')">Download to Halo 3</a>

當用戶單擊此鏈接時,地圖將下載到用戶Xbox 360。


選項1:

我嘗試打開一個隱藏的iframe然后在用戶單擊鏈接時將JavaScript加載到我的iframe 從而下載地圖。 唯一的問題是它不起作用。

> <iframe name="download_frame"
> src="http://www.bungie.net/Online/Halo3UserContentDetails.aspx?h3fileid=1244"
> width="0px" height="0px"></iframe> <a
> href="javascript:__doPostBack('ctl00$mainContent$xboxDownloadButton','')"
> target="download_frame">Download</a>

選項2:

是否有可能與src這樣的鏈接...

URL + JavaScript

選項3:

關於如何使用戶無需訪問此網站即可下載此地圖的任何其他建議都很好。

我不知道這是否行得通...應該將其視為偽代碼,因為在進行過程中我並未對此進行測試,但可能會有所幫助。

擁有一個用作IFRAME的標准HTML頁面怎么樣,我們稱之為“ dl.html”

dl.html中包含以下Javascript:

<script>
var file=location.has.replace('#','');
if (file) {
  var target='http://www.bungie.net/Online/Halo3UserContentDetails.aspx?h3fileid='+file;
  location.href=target;
}
</script>

在您的父HTML頁面中,執行以下操作:

<script>
  function downloadFile(id) {
    var f=document.createElement('iframe');
    f.setAttribute('id','whatever');
    f.style.border='0px';
    f.style.width='0px';
    f.style.height='0px';
    f.setAttribute('src','dl.html#'+id);
    fo = document.body.appendChild(f); 

  }
</script>
<a href="javascript:downloadFile('31604914')">Download to Halo 3</a>

希望能幫助或激發一些神經元...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM