Sunday, November 13, 2016

Navigate to new window from navbar link



When you create a list entry in navigation bar in order to set URL instead of select Page in this Application, by default the target of link is on current page so it's better when the link is out of your application this link navigates to either new window or tab on your browser.

First way is by Dynamic Action

1: Create a GLobal Page e.g. page 0
2: Create a Dynamic Action in Page Load event
   a.Name = > Go to new window in navbar Link
   b.Action => Execute JavaScript Code
c. Code :
$('.t-Button--navBar').attr("target", "_blank");

 



Second way it's a simple trick, only you should add below code in front of your address in URL Target
before change URL Target: http://oracleapex.blogfa.com/

after change URL Target: http://oracleapex.blogfa.com/" target="_blank"




After that I have begun to be curious about what will happen for href in (a tag) so these images were surveyed in (Chrome, Firefox, IE).

Chrome

 Firefox

IE 


Any way it works correctly.



3 comments :

  1. Nice post Saeed.

    My solution to this issue I had a couple of months ago was to enter a -no, actually two- javascript commands into the URL target rather than the plain URL:
    javascript:window.open('http://www.somewhere.com', '_blank');void(0);

    Without the void(0) the URL would open in a new window or tab but also the current window/tab running the apex app would show just a plain white page with the text "[object Window] only".

    A more handy solution in my opinion. Try it out ;-)

    Greetings
    Michael

    ReplyDelete
    Replies
    1. Hi Michael,

      Thank you for your comment. I respect to your opinion and I appreciate you that said to me the another way.

      Regards
      Saeed

      Delete
    2. Thanks, works great and doesn't need a dynamic action, I couldn't get the second way to work in APEX 19.2

      Delete