This discussion is archived
1 Reply Latest reply: Jan 3, 2013 9:26 PM by 714270 RSS

Button Redirect to New Tab Window Question

956009 Newbie
Currently Being Moderated
I would like to have a button that when clicked once, redirects the page to a URL in a new tab. The URL is based on a sql query from a dynamic action linked to the button.

Way 1:

I have tried to use redirect_url() in the dynamic action itself.

<pre>
htp.init;
owa_util.redirect_url('http://myurl.com');
</pre>

But it didn't work at all.

So I tried ...

Way 2:

1. In the dynamic action set a page item value to the url. This is Action 1 of the dynamic action.

<pre>
:P33_URL_ITEM := function_that_returns_the_url;
</pre>

2. Submit the page. This is Action 2 of the dynamic action.

3. Action 3 of the dynamic action executes the following JavaScript code:

<pre>
window.location.href="&P33_URL_ITEM.";
</pre>

However, the problem is P33_URL_ITEM is not set the first time (or whenever the session is cleared), so that the button has to be clicked twice in order for the page to be redirected.

Not-important question: Does anyone know how to fix it so that only 1 click is needed?

Way 3:

Use APEX Branch.

Important question: Does anyone know how to make the branch open the URL in a new page?

Thanks
  • 1. Re: Button Redirect to New Tab Window Question
    714270 Pro
    Currently Being Moderated
    953006 wrote:
    I would like to have a button that when clicked once, redirects the page to a URL in a new tab. The URL is based on a sql query from a dynamic action linked to the button.

    Way 1:

    I have tried to use redirect_url() in the dynamic action itself.

    <pre>
    htp.init;
    owa_util.redirect_url('http://myurl.com');
    </pre>

    But it didn't work at all.

    So I tried ...

    Way 2:

    1. In the dynamic action set a page item value to the url. This is Action 1 of the dynamic action.

    <pre>
    :P33_URL_ITEM := function_that_returns_the_url;
    </pre>

    2. Submit the page. This is Action 2 of the dynamic action.

    3. Action 3 of the dynamic action executes the following JavaScript code:

    <pre>
    window.location.href="&P33_URL_ITEM.";
    </pre>

    However, the problem is P33_URL_ITEM is not set the first time (or whenever the session is cleared), so that the button has to be clicked twice in order for the page to be redirected.

    Not-important question: Does anyone know how to fix it so that only 1 click is needed?
    Can't you set the P33_URL_ITEM page item in a on-load pl/sql process? It is difficult to give a precise answer unless I see what you are doing the page.
    Way 3:

    Use APEX Branch.

    Important question: Does anyone know how to make the branch open the URL in a new page?
    This thread might help:
    Open URL in new window when button pressed

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points