SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    links set to open in new window, are being treated as a pop-up under chrome?

    Title: When I try to click and launch links set to open in new window, it is being treated as a pop-up window under google chrome.

    Hi all,

    For the past few days, we are facing issue with the chrome browser behavior. This is related to opening links set to open in new tab/window. The details are as follow:

    I have a collection of links and each link points to different resource to be opened in a new tab/window. The code is as follow:

    <a class="cssClass" rid="1114931" href="http://www.domain.com/resources/abc.html" title="Link1" tabindex="4">Link 1</a>

    And there are few checks/filters over accessing the resources which have been implemented as onClick handler over the links. In case any of the validations fails, the onClick handler returns false and the default behavior of the link does not happens i.e. links does not get open.

    One of such (last) checks includes AJAX call in sync mode. The code is as follow:

    ....
    ....

    Code:
    var link_clickHandler = function(evt/* Event */) {
        var objTarget = jQuery(evt.target);
    
        if(check1) {
            return false;
        }
        else if(check2) {
            return false;
        }
        else if(check3) {
            var blnRetVal = false;
    
            jQuery.ajax( {
                "async" : false,
                "type" : "GET",
                "contentType" : "application/json; charset=utf-8",
                "url" : "index.php",
                "data" : 'resourceid=' + intResourceId,
                "dataType" : "json",
                "forceData" : true,
                "success" : function(data) {
                    if(check1) {
                        blnRetVal = true;
                    }
                }
                "error" : function(error) {
                }
            } );
    
            return blnRetVal;
        }
    };
    
    jQuery("a.cssClass").live("click", link_clickHandler);

    ISSUE: The issue is that Chrome is behaving very weirdly manner. In case all of the checks are passed and onClick handler returns true, sometimes the resource get opened in a new tab/window and sometimes it get opened as a pop-up (which should never). Tried to capture any pattern but could not succeed.

    Any solution or even helping in understanding behavior would be really appreciated.

    Thanks & Regards,
    Test Developer.
    Last edited by Pullo; Nov 28, 2013 at 08:34. Reason: Added code tags

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,000
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi,

    I've had a similar issue in the past, but could never be bothered to get to the bottom of it.
    Maybe now is a good time

    So you have a link set to open in a new tab/window. How is this happening?
    There is nothing in the code you posted to indicate this.

    Code:
    <a class="cssClass" rid="1114931" href="http://www.domain.com/resources/abc.html" title="Link1" tabindex="4">Link 1</a>
    What would be great, is if we could make a test page that exhibited the incorrect behaviour which doesn't involve AJAX.
    Do you think that would be possible?

  3. #3
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Pullo,

    First of all, thanks for taking out time to respond to issue.

    And yes I missed the target attribute under the link. The HTML code actually is as follow.

    Code:
    <a class="cssClass" rid="1114931" href="http://www.domain.com/resources/abc.html" title="Link1" tabindex="4" target="_blank">Link 1</a>
    I will give a test shot without AJAX but would not be able to remove it as it is a part of basic requirement. Would update with my observations.

    Thanks,
    Test Developer.

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    6,000
    Mentioned
    219 Post(s)
    Tagged
    12 Thread(s)
    Hi there,

    No problem
    I'm not suggesting that you remove the AJAX, rather that we remove it as a possible cause of this behaviour.
    In cases like this it always helps to reproduce the problem with the minimum amount of code, then you have a much better idea of where to start looking.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •