Briskstar Technologies
Briskstar Technologies

Reputation: 2251

Execute href and Open URL in a new window

I have postback method in asp.net and after that I want to open new blank page.

I am displaying some message from client side and explicitly clicking a href but that href is not firing.

<a href="../tools/pagename.aspx" target="_blank" id="aProcess"></a>

function DownloadData()
{
   $("#aProcess").click();
}

I want to execute href in new page. window.open() which I do not want to use. I want to open new window. using window.open() as it may blocked by browser sometime. Therefore a href call explicitly I want to trigger.

Upvotes: 0

Views: 5633

Answers (4)

Ramin Omrani
Ramin Omrani

Reputation: 3761

In order to open a new browser window with jquery you can use window.open() method:

window.open(URL,name,specs,replace)

URL: Optional. Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened.

name:Optional.Specifies the target attribute or the name of the window.

specs:Optional. A comma-separated list of items.

replace:Optional.Specifies whether the URL creates a new entry or replaces the current entry in the history list(true||false).

to open your page:

$("a#aProcess").click(function(){
    window.open('http://localhost:port/...','_blank');
});

Upvotes: 1

Mohebifar
Mohebifar

Reputation: 3411

    $("a#aProcess").click(function(e) {
        e.preventDefault();
        window.open($(this).attr('href'), '_blank');
    });

Upvotes: 0

dlock
dlock

Reputation: 9577

Use this if you want the url to be opened in the current window

document.location.href = 'http://url.com';

If you want the url opened in a new window without using window.open(). You can use

window.showModalDialog("http://url.com",window);

Upvotes: 0

giammin
giammin

Reputation: 18958

for change current page url:

function DownloadData()
{
   window.location = 'new url';
}

for opening new page:

window.open(url);

This is the only thing you can do if browser settings permit it.

Fortunately!

If it was different i think that will be impossible to surf the web without having tons of popup opened

Upvotes: 0

Related Questions