Window.Open () не работает при передаче закодированного URL - PullRequest
0 голосов
/ 26 апреля 2019

Я передаю путь к файлу для загрузки листа Excel через компонент encodeURI, и я передаю закодированный URL-адрес методу window.open () в javascript, но в результате происходит открытие новой вкладки, но она не закрывается даже после файлаполучил скачать.закодированный путь к файлу декодируется в том виде, в котором я плохо разбираюсь в javascript

путь к файлу, который я передаю:

/royallondon/en-gb/royallondon-new/DownloadTool/GetDividendHistoryFile?modelString={%22GrsProjectId%22:%2228600023%22,%22ProjectName%22:%22royallondon%22,%22ToolId%22:18,%22LanguageId%22:%221%22,%22LanguageCode%22:%22en-gb%22,%22OverrideDocumentCountryCode%22:null,%22forSaleIn%22:%22%22,%22FSIexclCT%22:%22%22}&filtersString={%22TypeCode%22:%22FP:NQE8%22,%22FundName%22:%22RLPPC%20Enhanced%20Buy%20and%20Maintain%20Credit%20Pn%20Inc%22,%22BaseCurrency%22:%22%22,%22PriceType%22:%22%22,%22StartDate%22:null,%22EndDate%22:null}&sectionId=30608109

путь закодированного файла после передачи пути к файлу в encodeURIcomponent:

"/LoadDoc?FilePath=%2Froyallondon%2Fen-gb%2Froyallondon-new%2FDownloadTool%2FGetDividendHistoryFile%3FmodelString%3D%7B%22GrsProjectId%22%3A%2228600023%22%2C%22ProjectName%22%3A%22royallondon%22%2C%22ToolId%22%3A18%2C%22LanguageId%22%3A%221%22%2C%22LanguageCode%22%3A%22en-gb%22%2C%22OverrideDocumentCountryCode%22%3Anull%2C%22forSaleIn%22%3A%22%22%2C%22FSIexclCT%22%3A%22%22%7D%26filtersString%3D%7B%22TypeCode%22%3A%22FP%3ANQE8%22%2C%22FundName%22%3A%22RLPPC%2520Enhanced%2520Buy%2520and%2520Maintain%2520Credit%2520Pn%2520Inc%22%2C%22BaseCurrency%22%3A%22%22%2C%22PriceType%22%3A%22%22%2C%22StartDate%22%3Anull%2C%22EndDate%22%3Anull%7D%26sectionId%3D30608109&themeName=royallondon-new&projectName=royallondon"

используемый код:

var absolutePath = '/' + GetLoader(loaderIdentifier) + '?FilePath=' + encodeURIComponent(filePath) + "&themeName=" + modelContents.Theme + "&projectName=" + modelContents.ProjectName;

if (!(eventObj) || !(eventObj.target) || !(eventObj.currentTarget) ||
    (eventObj.currentTarget.className != "fe-icon-chart"))
    window.open(absolutePath, (openWindowMethod == "" ? '_blank' : openWindowMethod));
else {
    window.open(absolutePath, (openWindowMethod == "" ? '_self' : openWindowMethod));
}

указанный код:

if (window == window.top)
            maximizeWindow();

$(function () {
    var filePath = getParameterByName('@ViewData["FilePath"]');
    if (filePath) {
         window.location.replace(filePath);
    }
    $("#loaderIcon").removeClass("loading-indicator").addClass("loading-indicator");
});

function maximizeWindow() {
    window.moveTo(0, 0);
    if (document.all) {
        top.window.resizeTo(screen.availWidth, screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
        if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
            top.window.outerHeight = screen.availHeight;
            top.window.outerWidth = screen.availWidth;
        }
    }
}

function getParameterByName(filePath) {
    return decodeURIComponent(filePath.replace(/\+/g, ' '));
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...