Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • activha Friend
    #179519

    There is a bug when trying to open a link with tmpl=component using the script in the component.php

    if(window.parent == window) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , ‘&’);
    }

    When using for instance links for editing K2 items, the page opens in a loop with constant redirection due to this script.

    How can I correct it to avoid this behavior while keeping the use of the script in mobile devices (opening the pop up in new window ) ?

    Thanks for helping

    Thanh Nguyen Viet Friend
    #462661

    Hello activha,

    Please try to replace this code snippet:

    if(window.parent == window) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '&');
    }

    With this one:

    if(window.top!=window.self) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '&');
    }

    activha Friend
    #462685

    Thanks, this avoids looping through the window but the side effect is that the pop up opens and then directly opens its content in a new window with tmpl=component.

    What I would like to achieve is this but without the side effect 🙂

    Thanh Nguyen Viet Friend
    #462692

    <em>@activha 332391 wrote:</em><blockquote>Thanks, this avoids looping through the window but the side effect is that the pop up opens and then directly opens its content in a new window with tmpl=component.

    What I would like to achieve is this but without the side effect :-)</blockquote>

    Please try to update it to:

    if(window.top!=window.self && !window.opener) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '&');
    }

    activha Friend
    #462712

    Well this code opens it in the pop up window on the desktop and then automatically open it in a new window, so this is not it

    I have tried
    [PHP] if(window.top!=window.self && window.parent == window) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , ‘&’);
    }[/PHP]

    this works for desktop, for mobile this is not it yet. It opens the page in the same window so I have to manually go back with the browser button.

    Do you have an idea to open it in a new window for mobile devices only ?

    Wall Crasher Developer
    #462755

    Hi activha,

    Can you give a try with this and tell me the result ?

    if(window.parent == window && !window.opener) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '');
    }

    Hope it helps.

    Regards

    activha Friend
    #462832

    Hi,
    This code constantly loops on mobile devices, works on desktop though.

    The only one working for now is :
    (window.top!=window.self && window.parent == window)

    with the only problem that it opens in the same window so users have to move back with the browser button

    Wall Crasher Developer
    #462835

    Hi activha,

    Please tell me more detail about the loop issue.
    Which devices you use for testing?

    And please give a try with this.


    if(window.parent == window && !window.opener && window.location.href.test(/tmpl=component/gi)) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , '');
    }

    Hope it helps.

    Regards

    activha Friend
    #463155

    I use iPhone 4S for testing,

    This latest code seems to work ok but it had twice &tmpl=component at the end of the url.

    I sticked with
    [PHP]if(window.parent == window && !window.opener && window.location.href.test(/tmpl=component/gi)) {
    window.top.location.href = window.location.href.replace(/(&*)tmpl=component/ , ”);
    }[/PHP]

    which is working.

    Wall Crasher Developer
    #463245

    Hi activha,

    I am not sure I can understand what you mean about the url has twice &tmpl=component at the end.
    Anyway, I am happy that it work for you. :laugh:

    Regards

Viewing 10 posts - 1 through 10 (of 10 total)

This topic contains 10 replies, has 3 voices, and was last updated by  Wall Crasher 12 years, 3 months ago.

We moved to new unified forum. Please post all new support queries in our New Forum