skip to Main Content

In Magento 1.9.0.1 using Owl carousel for display new arrival products. If I click the first product in desktop view it should open in new tab but in mobile view, same should open in the same tab.

Can anyone help with this? Thanks in advance

3

Answers


  1. If you set the target attribute to “_blank”, the link will open in a new browser window or a new tab.

    Login or Signup to reply.
  2. You can use this function to detect a mobile device in JavaScript and change target attribute.

    if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
        document.getElementById("link").target = "_self";     //change target
    }
    

    HTML code -like this:

    <a id="link" href="/something" target="_blank">Click Me</a>
    
    Login or Signup to reply.
  3. You can use

     window.open(url, '_blank');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search