Ext.js - Open all external links in a new tabHow to make a link open in tabbed or new window without target attribute?Open a URL in a new tab (and not a new window) using JavaScriptProgrammatically open html link in new tabIs it possible to switch to previously opened tab instead of opening a new one?Open iFrame links in a new tab?href=“javascript:” open in new tabOpen specific link in new tab on pageloadWindow.open opening blank new tab?Sweetalert2: open external link in new tab on YesOpen and reload single tab on clicking a link opened in two different tabs

Who determines when road center lines are solid or dashed?

What is this green alien supposed to be on the American covers of the "Hitchhiker's Guide to the Galaxy"?

Why did my "seldom" get corrected?

Company looks for long-term employees, but I know I won't be interested in staying long

Why teach C using scanf without talking about command line arguments?

Why jet engines sound louder on the ground than inside the aircraft?

The most secure way to handle someone forgetting to verify their account?

How fast does a character need to move to be effectively invisible?

Strategy to pay off revolving debt while building reserve savings fund?

Why do space operations use "nominal" to mean "working correctly"?

How to interpret a promising preprint that was never published?

Is there a difference between PIO and GPIO pins?

Term “console” in game consoles

Is encryption still applied if you ignore the SSL certificate warning for self signed?

Amira L'Akum not on Shabbat

What happens if a company buys back all of its shares?

Finding all possible pairs of square numbers in an array

Is surviving this (blood loss) scenario possible?

How to remove the first colon ':' from a timestamp?

What are the basics of commands in Minecraft Java Edition?

Difference between c++14 and c++17 using: `*p++ = *p`

Round command argument before using

Practical example in using (homotopy) type theory

Why isn't a binary file shown as 0s and 1s?



Ext.js - Open all external links in a new tab


How to make a link open in tabbed or new window without target attribute?Open a URL in a new tab (and not a new window) using JavaScriptProgrammatically open html link in new tabIs it possible to switch to previously opened tab instead of opening a new one?Open iFrame links in a new tab?href=“javascript:” open in new tabOpen specific link in new tab on pageloadWindow.open opening blank new tab?Sweetalert2: open external link in new tab on YesOpen and reload single tab on clicking a link opened in two different tabs






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








3















Maybe somebody has already faced with this problem.
I need to make all external links to open in a new browser tab.



The solution seems to be easy: just adding target="_blank" to each link with external domain, but how can I implement it in a nice way, because whole app is written in Ext.js.










share|improve this question




























    3















    Maybe somebody has already faced with this problem.
    I need to make all external links to open in a new browser tab.



    The solution seems to be easy: just adding target="_blank" to each link with external domain, but how can I implement it in a nice way, because whole app is written in Ext.js.










    share|improve this question
























      3












      3








      3








      Maybe somebody has already faced with this problem.
      I need to make all external links to open in a new browser tab.



      The solution seems to be easy: just adding target="_blank" to each link with external domain, but how can I implement it in a nice way, because whole app is written in Ext.js.










      share|improve this question














      Maybe somebody has already faced with this problem.
      I need to make all external links to open in a new browser tab.



      The solution seems to be easy: just adding target="_blank" to each link with external domain, but how can I implement it in a nice way, because whole app is written in Ext.js.







      javascript extjs extjs4 extjs4.2






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 '14 at 8:22









      Pavel TitenkovPavel Titenkov

      731 gold badge2 silver badges7 bronze badges




      731 gold badge2 silver badges7 bronze badges






















          4 Answers
          4






          active

          oldest

          votes


















          2














          You change target attributes with JavaScript:



          var tlinks = document.getElementsByTagName('a');
          for (var i=0;i<tlinks.length;i++)
          if (tlinks[i].href.indexOf('http://www.yourownurlhere.com') == -1)
          tlinks[i].setAttribute('target', '_blank');




          Remember to replace "yourownurlhere.com" with your actual url






          share|improve this answer






























            2














            The trick can be done with event delegation.



            Ext.select('body').on('click', function (e, el) 
            el.target = '_blank';
            , null, delegate: 'a');


            Note that if you write just



            Ext.select('a').on('click', function (e, el) 
            el.target = '_blank';
            );


            then you apply handler only to existing links. However, delegation also handles elements created afterwards. If you want such behaivor for links included only in certain container, you may change 'body' to any selector that matches that container.



            Here is jsfiddle






            share|improve this answer






























              0














              I decided to answer my own question, because maybe it will be useful for anybody.
              The only way to catch all clicks on the links is to control body clicks (as triclozan wrote in his answer).


              This code will modify every link after clicking and will open it in the new window:



              Ext.getBody().addListener('click', function (event, el) 
              var clickTarget = event.target;

              if (clickTarget.href && clickTarget.href.indexOf(window.location.origin) === -1)
              clickTarget.target = "_blank";

              );


              Hope this code will save few hours of googling for somebody with the same problem :)






              share|improve this answer






























                0














                You can simply do :



                window.open("Your link");






                share|improve this answer

























                  Your Answer






                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "1"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader:
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  ,
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22628871%2fext-js-open-all-external-links-in-a-new-tab%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  2














                  You change target attributes with JavaScript:



                  var tlinks = document.getElementsByTagName('a');
                  for (var i=0;i<tlinks.length;i++)
                  if (tlinks[i].href.indexOf('http://www.yourownurlhere.com') == -1)
                  tlinks[i].setAttribute('target', '_blank');




                  Remember to replace "yourownurlhere.com" with your actual url






                  share|improve this answer



























                    2














                    You change target attributes with JavaScript:



                    var tlinks = document.getElementsByTagName('a');
                    for (var i=0;i<tlinks.length;i++)
                    if (tlinks[i].href.indexOf('http://www.yourownurlhere.com') == -1)
                    tlinks[i].setAttribute('target', '_blank');




                    Remember to replace "yourownurlhere.com" with your actual url






                    share|improve this answer

























                      2












                      2








                      2







                      You change target attributes with JavaScript:



                      var tlinks = document.getElementsByTagName('a');
                      for (var i=0;i<tlinks.length;i++)
                      if (tlinks[i].href.indexOf('http://www.yourownurlhere.com') == -1)
                      tlinks[i].setAttribute('target', '_blank');




                      Remember to replace "yourownurlhere.com" with your actual url






                      share|improve this answer













                      You change target attributes with JavaScript:



                      var tlinks = document.getElementsByTagName('a');
                      for (var i=0;i<tlinks.length;i++)
                      if (tlinks[i].href.indexOf('http://www.yourownurlhere.com') == -1)
                      tlinks[i].setAttribute('target', '_blank');




                      Remember to replace "yourownurlhere.com" with your actual url







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 25 '14 at 10:11









                      NillervisionNillervision

                      3911 silver badge10 bronze badges




                      3911 silver badge10 bronze badges























                          2














                          The trick can be done with event delegation.



                          Ext.select('body').on('click', function (e, el) 
                          el.target = '_blank';
                          , null, delegate: 'a');


                          Note that if you write just



                          Ext.select('a').on('click', function (e, el) 
                          el.target = '_blank';
                          );


                          then you apply handler only to existing links. However, delegation also handles elements created afterwards. If you want such behaivor for links included only in certain container, you may change 'body' to any selector that matches that container.



                          Here is jsfiddle






                          share|improve this answer



























                            2














                            The trick can be done with event delegation.



                            Ext.select('body').on('click', function (e, el) 
                            el.target = '_blank';
                            , null, delegate: 'a');


                            Note that if you write just



                            Ext.select('a').on('click', function (e, el) 
                            el.target = '_blank';
                            );


                            then you apply handler only to existing links. However, delegation also handles elements created afterwards. If you want such behaivor for links included only in certain container, you may change 'body' to any selector that matches that container.



                            Here is jsfiddle






                            share|improve this answer

























                              2












                              2








                              2







                              The trick can be done with event delegation.



                              Ext.select('body').on('click', function (e, el) 
                              el.target = '_blank';
                              , null, delegate: 'a');


                              Note that if you write just



                              Ext.select('a').on('click', function (e, el) 
                              el.target = '_blank';
                              );


                              then you apply handler only to existing links. However, delegation also handles elements created afterwards. If you want such behaivor for links included only in certain container, you may change 'body' to any selector that matches that container.



                              Here is jsfiddle






                              share|improve this answer













                              The trick can be done with event delegation.



                              Ext.select('body').on('click', function (e, el) 
                              el.target = '_blank';
                              , null, delegate: 'a');


                              Note that if you write just



                              Ext.select('a').on('click', function (e, el) 
                              el.target = '_blank';
                              );


                              then you apply handler only to existing links. However, delegation also handles elements created afterwards. If you want such behaivor for links included only in certain container, you may change 'body' to any selector that matches that container.



                              Here is jsfiddle







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 25 '14 at 16:30









                              triclozantriclozan

                              2281 silver badge7 bronze badges




                              2281 silver badge7 bronze badges





















                                  0














                                  I decided to answer my own question, because maybe it will be useful for anybody.
                                  The only way to catch all clicks on the links is to control body clicks (as triclozan wrote in his answer).


                                  This code will modify every link after clicking and will open it in the new window:



                                  Ext.getBody().addListener('click', function (event, el) 
                                  var clickTarget = event.target;

                                  if (clickTarget.href && clickTarget.href.indexOf(window.location.origin) === -1)
                                  clickTarget.target = "_blank";

                                  );


                                  Hope this code will save few hours of googling for somebody with the same problem :)






                                  share|improve this answer



























                                    0














                                    I decided to answer my own question, because maybe it will be useful for anybody.
                                    The only way to catch all clicks on the links is to control body clicks (as triclozan wrote in his answer).


                                    This code will modify every link after clicking and will open it in the new window:



                                    Ext.getBody().addListener('click', function (event, el) 
                                    var clickTarget = event.target;

                                    if (clickTarget.href && clickTarget.href.indexOf(window.location.origin) === -1)
                                    clickTarget.target = "_blank";

                                    );


                                    Hope this code will save few hours of googling for somebody with the same problem :)






                                    share|improve this answer

























                                      0












                                      0








                                      0







                                      I decided to answer my own question, because maybe it will be useful for anybody.
                                      The only way to catch all clicks on the links is to control body clicks (as triclozan wrote in his answer).


                                      This code will modify every link after clicking and will open it in the new window:



                                      Ext.getBody().addListener('click', function (event, el) 
                                      var clickTarget = event.target;

                                      if (clickTarget.href && clickTarget.href.indexOf(window.location.origin) === -1)
                                      clickTarget.target = "_blank";

                                      );


                                      Hope this code will save few hours of googling for somebody with the same problem :)






                                      share|improve this answer













                                      I decided to answer my own question, because maybe it will be useful for anybody.
                                      The only way to catch all clicks on the links is to control body clicks (as triclozan wrote in his answer).


                                      This code will modify every link after clicking and will open it in the new window:



                                      Ext.getBody().addListener('click', function (event, el) 
                                      var clickTarget = event.target;

                                      if (clickTarget.href && clickTarget.href.indexOf(window.location.origin) === -1)
                                      clickTarget.target = "_blank";

                                      );


                                      Hope this code will save few hours of googling for somebody with the same problem :)







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Mar 28 '14 at 10:11









                                      Pavel TitenkovPavel Titenkov

                                      731 gold badge2 silver badges7 bronze badges




                                      731 gold badge2 silver badges7 bronze badges





















                                          0














                                          You can simply do :



                                          window.open("Your link");






                                          share|improve this answer



























                                            0














                                            You can simply do :



                                            window.open("Your link");






                                            share|improve this answer

























                                              0












                                              0








                                              0







                                              You can simply do :



                                              window.open("Your link");






                                              share|improve this answer













                                              You can simply do :



                                              window.open("Your link");







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Mar 26 at 10:01









                                              baidehi ghoshbaidehi ghosh

                                              11 bronze badge




                                              11 bronze badge



























                                                  draft saved

                                                  draft discarded
















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid


                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.

                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22628871%2fext-js-open-all-external-links-in-a-new-tab%23new-answer', 'question_page');

                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  Popular posts from this blog

                                                  Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                                  SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                                  은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현