JS Get URL Information of the Report

  • Last update:November 26, 2020
  • I. Description

    When developing reports, we may need to collect information about the URL of the currently opened report page. Although FineReport currently has some built-in system parameters that can meet certain needs, it is not perfect. For example, there is no system parameters that can get the title of a webpage.

    1606372995478320.png

    II. Example

    Open the file %FR_HOME%\webapps\webroot\WEB-INF\reportlets\GettingStarted.cpt and add a Click event for the "Query" button, as shown in the following figure:

    1606372995150119.png

    JavaScript code:

    var test1 = window.location.href;
    alert('URL:  '+test1);
    //window.location.protocol(get the protocal of URL)
    var test2 = window.location.protocol;
    alert('URL Protocol:  '+test2);
    //window.location.host(Get the host part of the URL)
    var test3 = window.location.host;
    alert('URL Host:  '+test3);
    //window.location.port(Get the port number with URL)
    var test4 = window.location.port;
    alert('URL Port:  '+test4);
    //window.location.pathname(Get the path part of the URL)
    var test5 = window.location.pathname;
    alert('URL Path Name:  '+test5);
    //window.location.search(Get the part of the URL attribute following the question mark)
    var test6 = window.location.search;
    alert('URL Search:  '+test6);
    //Get the page title corresponding to the URL
    var  test7  = document.title;
    alert('URL Title:  '+test7);

    After saving, the effect is as follows:

    1606372995181100.gif

    III. Completed Template

    Attachment List


    Theme: Secondary Development
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy