简体   繁体   English

加载URL + JavaScript操作

[英]Load URL + JavaScript action

I'm trying to get my users to download "maps" from bungie.net from my website. 我试图让我的用户从我的网站上的bungie.net下载“地图”。

Example map: 示例图:

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

Link users need to click to download map: 链接用户需要点击下载地图:

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

When a user clicks this link the map is downloaded to the users Xbox 360. 当用户单击此链接时,地图将下载到用户Xbox 360。


Option 1: 选项1:

I tried opening a hidden iframe then when the user clicks on a link JavaScript will load into my iframe . 我尝试打开一个隐藏的iframe然后在用户单击链接时将JavaScript加载到我的iframe Thus downloading the map. 从而下载地图。 The only problem is it doesn't work. 唯一的问题是它不起作用。

> <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>

Option 2: 选项2:

Is it possible to have a link with a src something like this... 是否有可能与src这样的链接...

URL + JavaScript

Option 3: 选项3:

Any other suggestions of how to get users to download this map without having to go to this website would be great. 关于如何使用户无需访问此网站即可下载此地图的任何其他建议都很好。

I don't know if this will work... it should be treated as pseudo-code as I'm not testing this as I go along but might help. 我不知道这是否行得通...应该将其视为伪代码,因为在进行过程中我并未对此进行测试,但可能会有所帮助。

How about having a standard HTML page for use as an IFRAME, lets call it "dl.html" 拥有一个用作IFRAME的标准HTML页面怎么样,我们称之为“ dl.html”

Within dl.html have the following Javascript: 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>

In your parent HTML page, have this: 在您的父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>

Hope that helps, or fires some neurons... 希望能帮助或激发一些神经元...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM