[JS] open save as widnow

Discussion in 'Programming' started by Kacyk, Aug 11, 2011.

  1. #1
    Hi, how to do, when i click link >>> {c = a.replace('/audio/', '/xml/file/') + '/site.com/sa/' + b; // Audio <<< will be open window save as ?. Thanks


    // Declare varsvar b = 0;
    var a, c, d, e, f, g = null;




    a = window.location.href;
    b = Math.floor((Math.random() * 10001));
    c = a.replace('/audio/', '/xml/file/') + '/site.com/sa/' + b; // Audio
    c = c.replace('/film/', '/xml/file/') + '/site.com/sa/' + b; // Video
    c = c.replace('/obraz/', '/xml/file/') + '/site.com/sa/' + b; // Images




    try {
    // Mozilla, Opera, Safari, Internet Explorer (<=7)
    d = new XMLHttpRequest();
    } catch (e) {
    try {
    // MS Internet Explorer (<=6)
    d = new ActiveXObject('Microsoft.XMLHTTP');
    } catch (e) {
    try {
    // MS Internet Explorer (<=5)
    d = new ActiveXObject('Msxml2.XMLHTTP');
    } catch (e) {
    d = null;
    }
    }
    }
    if (d) {
    d.open('GET', c, false);
    d.onreadystatechange = function () {
    if (d.readyState === 4) {
    // Best solution for most browsers (inc. IE / Trixie)
    e = d.responseText.match(/\<fileId\>\<\!\[CDATA\[((.)*)\]\]\>\<\/fileId\>/)[1];
    f = d.responseText.match(/\<name\>\<\!\[CDATA\[((.)*)\]\]\>\<\/name\>/)[1];
    g = document.getElementById('link');
    g.innerHTML = g.innerHTML + '<br /><br /><label for="link_file">Download:</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="' + e + '">' + f + '</a>&nbsp;&nbsp;<img src="data:image/gif;base64,R0lGODlhMgAPAIcAACAgQCAggCAgwCAg/yBAQCBAgCBAwCBA/yBgQCBggCBgwCBg/yCAQCCAgCCAwCCA/yCgQCCggCCgwCCg/yDAQCDAgCDAwCDA/yDgQCDggCDgwCDg/yD/QCD/gCD/wCD//0AgQEAggEAgwEAg/0BAQEBAgEBAwEBA/0BgQEBggEBgwEBg/0CAQECAgECAwECA/0CgQECggECgwECg/0DAQEDAgEDAwEDA/0DgQED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