JS Display Hyperlink Options when Mouse Moves in

  • Last update:January 15, 2021
  • I. Overview

    1.1 Problem Description

    When a cell contains multiple hyperlinks, you have to click the hyperlink first to pop up the hyperlink options and then choose the desired one. If the desired hyperlink can be choosed after only one click , the user experience will be better.

    In this document, a method is introduced to let all hyperlink options be displayed when the mouse moves to the hyperlink.

    2.gif

     

    1.2 Solution

    The cell's jQuery event mouseover can control the effect when mouse move to the cell, and event mouseout can control the effect when mouse move out of the cell.

    In addition, you need to determine whether there are hyperlinks in the cell or not.

    II. Example

    2.1 Design Report

    New normal report, the text in cell B2 is Hyperlink 1, and the text in cell B3 is Hyperlink 2.

    Add 3 hyperlinks to cell B2:

    Snag_ffa000a.png

    Add 1 hyperlink to cell B3:

    Snag_ffa37e2.png


    2.2 Add event

    Select Template > Web Attributes, select Pagination Preview and add a Loading End event:

    image.png

    The JS codes:

    $('td').mouseover(function(){
    //Set mouse move to cell event
    var $link=$(this).find('.linkspan');
    //If it contains a hyperlink
    if($link.length>0){
    //If it contains multiple hyperlink alternatives, the menu will pop up, otherwise it will not be processed
         if($link.attr('onclick').replace('return').indexOf('return')>=0){
         //Call a hyperlink click event
    $link.click();
    var x=window.event.x;
    var y=window.event.y;
    //Set the left and upper positions of the pop-up menu as the current position of the mouse, or modify it as needed
    $('.menu').css('left',x);
    $('.menu').css('top',y);
    }
    }
    }).mouseout(function(e){
    //Set the mouse out of the cell event, you need to hide the original menu
    var $link=$(this).find('.linkspan');
    if($link.length>0){
    var $target=$(e.toElement);
    if(!$target.hasClass('menu')){
    //Hide pop-up menu
    $('.menu').hide();
    }}
    })
    Show Code


    2.3 Show results

    Save report, select Pagination Preview and the results are as shown in the beginning.

    Tips: Not support mobile devices.

    III. Completed template

    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    9s后關閉

    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