locked
Open more then 1 new tab from VB RRS feed

  • Question

  • User1444011213 posted

    Hi,

    I have in VB on page load:

    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('1.aspx','_newtab');", True)
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('2.aspx','_newtab');", True)
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('3.aspx','_newtab');", True)

    But it only opens 1.aspx in new tab and <g class="gr_ gr_83 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar multiReplace" id="83" data-gr-id="83">do</g> not open 2.aspx or 3.aspx that I would like to be <g class="gr_ gr_77 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="77" data-gr-id="77">opend</g> in separate new tabs as well.

    Is there a way of doing <g class="gr_ gr_126 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar replaceWithoutSep" id="126" data-gr-id="126">of</g> this?

    Thx

    Thursday, December 20, 2018 10:36 AM

Answers

  • User753101303 posted

    Ah I mean the name of the tab that is :

    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('1.aspx','_newtab1');", True)
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('2.aspx','_newtab2');", True)
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('3.aspx','_newtab3');", True)

    Don't hesitate to check the doc. I tend to explain what needs to be done rather than ready copy to paste code so that what is done is understood. The first parameter is the url you want to open and the 2nd one is the name of the window (or tab) in which you want to open this. If the name is not needed, you could just omit that (the default name is "_blank" which should show the page in a new tab).

    Not sure what is it but it is quite long for a web app...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 20, 2018 2:16 PM
  • User1444011213 posted

    Hi,

    A correct script was given by Ackerly Xu in this post, but it was deleted for some reason, anyway the code is:
    .aspx:
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script>
    function OpenMultipleTabs()
    {
    window.open('/1.aspx', '_blank');
    window.open('/2.aspx', '_blank');
    window.open('/3.aspx','_blank');
    window.open('/4.aspx', '_blank');
    window.open('/5.aspx', '_blank');
    }
    </script>
    </asp:Content>

    VB:
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "OpenMultipleTabs()", True)
    End Sub

    Once again dear Ackerly Xu thanks you for solving my problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 24, 2018 7:05 AM

All replies

  • User753101303 posted

    Hi,

    What if you omit the tab name or give a different name for each ? It might be quite confusing for users. Make sure this is really your best option for what you are trying to do...

    Thursday, December 20, 2018 10:40 AM
  • User1444011213 posted

    Hi,

    This is for my admin backend, I wish to open at once all pages needed to be opened for <g class="gr_ gr_86 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="86" data-gr-id="86"><g class="gr_ gr_91 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins doubleReplace replaceWithoutSep" id="91" data-gr-id="91">certan</g></g> task.

    Thanks for replay

    Thursday, December 20, 2018 11:28 AM
  • User1444011213 posted

    I do not understand what do you mean by this:

    What if you omit the tab name or give a different name for <g class="gr_ gr_29 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" id="29" data-gr-id="29">each ?</g>

    Thursday, December 20, 2018 11:28 AM
  • User753101303 posted

    By giving the same name you likely cause all pages to open in the same tab each one replacing the other one. This is why I would try without giving a name first or a different name for each.

    Note sure what is the task at hand but having to switch from a tab to another is perhaps not that convenient. I would rather have a general dashboard that can be monitored and based on that the admin could go to the needed page, do whatever needs to be done and be back on the dashboard. The admin can still open a new tab if HE needs to by using the context menu.

    Here you are forcing an approach they could maybe dislike.

    Thursday, December 20, 2018 1:07 PM
  • User1444011213 posted

    HI,

    Thanks for replay, I still do not understand this "By giving the same name", the names are different: 1.aspx, 2.aspx, 3.aspx....

    I need to open separate tab since the process on each tab takes about 5 minutes to complete (tested by opening all of them manually in the same time), when I program it to run when one-page finish to open the second page... it takes over 2h.

    Thx

    Thursday, December 20, 2018 1:40 PM
  • User753101303 posted

    Ah I mean the name of the tab that is :

    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('1.aspx','_newtab1');", True)
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('2.aspx','_newtab2');", True)
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "window.open('3.aspx','_newtab3');", True)

    Don't hesitate to check the doc. I tend to explain what needs to be done rather than ready copy to paste code so that what is done is understood. The first parameter is the url you want to open and the 2nd one is the name of the window (or tab) in which you want to open this. If the name is not needed, you could just omit that (the default name is "_blank" which should show the page in a new tab).

    Not sure what is it but it is quite long for a web app...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 20, 2018 2:16 PM
  • User1444011213 posted

    Hi,

    A correct script was given by Ackerly Xu in this post, but it was deleted for some reason, anyway the code is:
    .aspx:
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script>
    function OpenMultipleTabs()
    {
    window.open('/1.aspx', '_blank');
    window.open('/2.aspx', '_blank');
    window.open('/3.aspx','_blank');
    window.open('/4.aspx', '_blank');
    window.open('/5.aspx', '_blank');
    }
    </script>
    </asp:Content>

    VB:
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    Page.ClientScript.RegisterStartupScript(Me.[GetType](), "OpenWindow", "OpenMultipleTabs()", True)
    End Sub

    Once again dear Ackerly Xu thanks you for solving my problem.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 24, 2018 7:05 AM