1 2 Previous Next 15 Replies Latest reply: Aug 20, 2013 2:24 AM by Diganta_C RSS

    Open in new Tab

    Diganta_C

      How to open links in a new tab in the browser for the links column under tree structure?

        • 1. Re: Open in new Tab
          Nicolette

          user13542406

           

          You can use window.open() to open a new browser window.

          If this new window opens as a new tab in the browser or not is controlled by the browser settings.

           

          Nicolette

          • 2. Re: Open in new Tab
            Diganta_C

            Hi Nicolette,

             

            My tree attributes query is like this :

             

            select case when connect_by_isleaf = 1 then 0

                        when level = 1             then 1

                        else                           -1

                   end as status,

                   level,

                   d as title,

                   null as icon,

                   id as value,

                   t as tooltip,

                   link as link

            from

            (

            select 'G'||g.tab_group_id id, null parent, g.tab_group_label d, null link, g.tab_group_description t

              from cdp_tab_groups g

              where tab_id=43 and display_yn = 'Y'  

            union

            select 'I'||ti.tab_item_id id, 'G'||tg.tab_group_id parent, ti.tab_item_label d, ti.tab_item_url link, tab_item_description t

              from cdp_tab_items ti,

                   cdp_tab_groups tg

            where ti.tab_group_id = tg.tab_group_id

            )

            start with parent is null

            connect by prior id = parent

            order siblings by d

             

            I want to have "ti.tab_item_url" column onclick points to a new tab.

            • 3. Re: Open in new Tab
              Nicolette

              Diganta_c

               

              In the select of the tab items change the link to:

              select 'I'||ti.tab_item_id id,
                    'G'||tg.tab_group_id parent,
                    ti.tab_item_label d,
                    'javascript:window.open('||ti.tab_item_url||',"_blank");' link,
                    tab_item_description t
                from cdp_tab_items ti,
                     cdp_tab_groups tg
              where ti.tab_group_id = tg.tab_group_id
              

               

              Google for more information window.open.

               

               

              Nicolette

              • 4. Re: Open in new Tab
                Diganta_C

                Hi Nicolette,

                 

                I tried the codes above but now onclick on the link there is no action. Its not doing anything.

                 

                Thanks,

                Diganta C

                • 5. Re: Open in new Tab
                  Nicolette

                  Diganta C

                   

                  And what error message does your browser developer tool give?

                  Can you set up what you have done on apex.oracle.com. so I can have look.

                   

                  Nicolette

                  • 6. Re: Open in new Tab
                    Mohan1312

                    hi,

                     

                    try this,

                     

                    select case when connect_by_isleaf = 1 then 0

                                when level = 1             then 1

                                else                           -1

                           end as status,

                           level,

                           d as title,

                           null as icon,

                           id as value,

                           t as tooltip,

                          '<a href="'||link||'">link</a>' END AS "link"

                    from table_name

                    add your sub-query instead of table name here it ll work.

                     

                    Regards,

                    Mohan.

                    • 7. Re: Open in new Tab
                      Diganta_C

                      Hi Mohan,

                      I am getting this below error:

                       

                       

                      http://st-curr-dev.us.oracle.com/i/f_spacer.gif

                      Parse error: 

                      ORA-00923: FROM keyword not found where expected

                      http://st-curr-dev.us.oracle.com/i/htmldb/builder/rollup_minus_dgray.gifTechnical Info (only visible for developers)
                      • is_internal_error: true
                      • apex_error_code: WWV_FLOW_SVG.PARSE_ERROR
                      • ora_sqlcode: -923
                      • ora_sqlerrm: ORA-00923: FROM keyword not found where expected
                      • component.type: APEX_APPLICATION_PAGE_REGIONS
                      • component.id: 2616929467650624
                      • component.name: Resources
                      • error_backtrace: ORA-06512: at "SYS.DBMS_SYS_SQL", line 1249 ORA-06512: at "SYS.WWV_DBMS_SQL", line 264 ORA-06512: at "APEX_040200.WWV_FLOW_DYNAMIC_EXEC", line 337 ORA-06512: at "APEX_040200.WWV_FLOW_TREE_REGION", line 285

                       

                      http://st-curr-dev.us.oracle.com/i/f_spacer.gif

                      The query used was as follows:

                      select case when connect_by_isleaf = 1 then 0

                                  when level = 1             then 1

                                  else                           -1

                             end as status,

                             level,

                             d as title,

                             null as icon,

                             id as value,

                             t as tooltip,

                                        '<a href="'||link||'">link</a>' end AS "link"

                      from

                      ..... sub queries

                       

                      Please check.

                       

                      Thanks

                      Diganta C

                       

                      • 8. Re: Open in new Tab
                        Diganta_C

                        Hi Nicolette,

                         

                        I am not getting errors, the page displays normally. But the moment I click on the tree nodes its not taking me to anywhere.

                         

                        Thanks

                        Diganta C

                        • 9. Re: Open in new Tab
                          Mohan1312

                          remove the end key word    '<a href="'||link||'">link</a>' AS "link"




                          • 10. Re: Open in new Tab
                            Diganta_C

                            Hi Mohan,

                            Now the page displays correctly, but the moment I click on the tree node it throws error as "

                            Bad Request

                            The request could not be understood by server due to malformed syntax."

                            • 11. Re: Open in new Tab
                              Mohan1312

                              once the your done with that go to the edit page

                              then click on the report and go to report attributes tab

                              in that tab change the display text as  =>  standard report column for the link attribute 

                              • 12. Re: Open in new Tab
                                Diganta_C

                                Hi Mohan,

                                 

                                I am not working of report. The query is used on Tree structure and there is no report attributes. I have put the page template as standard region.

                                 

                                Thanks,

                                DC

                                • 13. Re: Open in new Tab
                                  Mohan1312

                                  try this website i guess you find the answer in this site

                                   

                                  http://www.oracle.com/technetwork/developer-tools/apex/howto-tree-088504.html#create

                                  • 14. Re: Open in new Tab
                                    Nicolette

                                    Diganta C

                                     

                                     

                                    That is what you get when you post before testing;

                                    I had forgotten the enclose the url in " .

                                    But after some testing I have come to the conclusion that it isn't that simple.

                                    With using javascript directly as the url the page was still redirecting but now to an empty page.

                                    To stop that the url of the link has to be #.

                                     

                                    Now how to get it working.

                                     

                                    Make a dynamic action with as selector type "jQuery selector" and the selector ".leaf > a".

                                    The event is click. The action is 'execute Javascript code'

                                     

                                    With the following code:

                                     

                                    var element = this.triggeringElement,
                                      vUrl,
                                      vHref,
                                      vParent;
                                    
                                    /*The triggering has no id attribute 
                                    **luckily its parent does 
                                    **set aside we need it later*/
                                    vParent=element.parentNode.id;
                                    
                                    /*Get the attribute with the name href of the link*/
                                    vHref=element.attributes.getNamedItem('href').value;
                                    
                                    /*If the href is not #
                                    **link is not clicked before
                                    */
                                    if (vHref !=='#'){
                                      /*Get the url including the base url*/
                                      vUrl = element.href;
                                      
                                      /*Store the url in a data attribute of the parent*/
                                      apex.jQuery('#'+vParent).data('page_url',vUrl);
                                    
                                      /*Set the href attribute to #
                                      **so the link doesn't go any where*/
                                      element.href = '#';
                                    } else {
                                      /*Leaf is already clicked
                                      **get the url from the parent
                                      **it is stored in a data attribute
                                      */
                                      vUrl = apex.jQuery('#'+vParent).data('page_url');
                                    }
                                    /*Open the url in a new window*/ 
                                    window.open(vUrl,'_blank');
                                    
                                    /*Prevent the default behaviour of the link*/
                                    return false;

                                     

                                    To see the above in action see this demo.

                                    Let me know if anything is unclear on the how or why.

                                     

                                    Nicolette

                                    1 2 Previous Next