ritacse
10/7/2018 - 8:40 AM

URL/Link rederection in new tab

 
if (window.location.hostname.indexOf("192") > -1) /// Not provid ethe full link
  var redirect = 'http://192.168.200.35:5693/ApprovalHRMS/API/ExternalCommunicationHandler.ashx';

  else
     var redirect = 'http://localhost:8222/API/ExternalCommunicationHandler.ashx';
     
     
//Tips
    window.location.host : you'll get sub.domain.com:8080 or sub.domain.com:80
    window.location.hostname : you'll get sub.domain.com
    window.location.protocol : you'll get http:
    window.location.port : you'll get 8080 or 80
    window.location.pathname : you'll get /virtualPath
    window.location.origin : you'll get http://sub.domain.com *****


//ditect page name
     var pageName = document.location.pathname.match(/[^\/]+$/)[0];
    var pageName2 = location.pathname.split('/').slice(-1)[0];
    var href = document.location.href;
    var lastPathSegment = href.substr(href.lastIndexOf('/') + 1);
 // send parameter 
 var url = '../ApprovalReportViewer.aspx?docBaseId=' + aData.Doc_Type + "&docCode=" + aData.Code + "&docVersion=" + aData.Version;
     window.open(url, '_blank');   // <- This is what makes it open in a new window.     
     
     
     //Get parameter 
    var docBaseId = $.url().param('docBaseId');
    var docCode = $.url().param('docCode');
    var docVersion = $.url().param('docVersion');
    
    //Or
    var docBaseId = GetParameterValues('docBaseId');
    var docCode = GetParameterValues('docCode');
    var docVersion = GetParameterValues('docVersion');
    
    function GetParameterValues(param) {
    var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < url.length; i++) {
        var urlparam = url[i].split('=');
        if (urlparam[0] == param) {
            return urlparam[1];
        }
    }
}
 var url = '../../HTMLReports/frmRptKPIEmpWiseAchievementDetails.aspx?EmpId=' + group1[i].EmpId + "&AchieveMonth=" + group1[i].TargetFromMonth + "&AchieveYear=" + group1[i].TargetFromYear;

///static
<td> <a href="url" target="_blank">A K Shams   Noor(1053)</a> </td>

///Dynamic
'<td style="text-align:center;"><a href="' + url + '" target="_blank">' 
            + group1[i].EmpNameEng + '(' + group1[i].EmpId + ')' 
+ '</a></td>' 
/// Report open from approval system without external Login
/// Example from : \DMS\DMS.Planning.Web\Scripts\Planning\YarnAllocation.js

function RefFBLink(fbCode, fbVersion) {

    var ReportName = 'rptFabricBooking.aspx';
    var DocBaseID = 63;

    if (fbCode == 'N/A' || fbCode == null || fbCode =='')
        toastr.warning("Fabric booknig does not found against this job.",'Invalid');

    else {
        //var urlLink = 'http://localhost:59780/ApprovalSystem/htmlReport/' + ReportName + '?clientAgent=Web&userId=' + 0 + '&docBaseId=' + DocBaseID + '&docCode=' + fbCode + '&docVersion=' + fbVersion;
        var urlLink = 'http://172.16.1.8/ApprovalSystem/htmlReport/' + ReportName + '?clientAgent=Web&userId=' + 0 + '&docBaseId=' + DocBaseID + '&docCode=' + fbCode + '&docVersion=' + fbVersion;

        window.open(urlLink);
    }
}