Open New Window and Redirect Old

G

Greg Collins [MVP]

I've searched around and can't seem to find an answer to this... maybe someone has already done it.

I want to create a redirection page for hyperlinks which point to an external site or file. This is so that I can keep track of how many visitors are linking to external resources from the site using the hosting server's statistics package.

Due to technical constraints that I don't want to get into right here, I am unable to have the original link open the new browser window... I need to be able to do this with aspx code.

Here's what I want to do: When a user clicks a link on a page, they go to a link such as the following:

http://www.mysite.com/redirect.aspx?url=http://www.offsite.com/folder/file.zip

When they get to the redirect.aspx page, I want to:

1. Open a new blank browser window which will load the offsite url.
2. Redirect back to the referring url with no history of having visted the redirection page.

Is this even possible?
 
S

Steve C. Orr [MVP, MCSD]

Sounds like a job for client side javascript:
window.open('MyPage.aspx','_blank');
history.go(-1);

Here's more info:
http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/open_0.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net





I've searched around and can't seem to find an answer to this... maybe
someone has already done it.

I want to create a redirection page for hyperlinks which point to an
external site or file. This is so that I can keep track of how many visitors
are linking to external resources from the site using the hosting server's
statistics package.

Due to technical constraints that I don't want to get into right here, I am
unable to have the original link open the new browser window... I need to be
able to do this with aspx code.

Here's what I want to do: When a user clicks a link on a page, they go to a
link such as the following:


http://www.mysite.com/redirect.aspx?url=http://www.offsite.com/folder/file.zip

When they get to the redirect.aspx page, I want to:

1. Open a new blank browser window which will load the offsite url.
2. Redirect back to the referring url with no history of having visted
the redirection page.

Is this even possible?
 
G

Greg Collins [MVP]

Is there no way to do this serverside? I'd rather not have to go clientside if I can at all avoid it.
 
S

Steve C. Orr [MVP, MCSD]

Not really, this is client side functionality controlled by the browser, so
you have to talk directly with the browser.
However, you can output this client side code from your server side code.
For example, try this server code:
RegisterStartupScript("startupScript", "<script
language=JavaScript>window.open('test.aspx','_blank');</script>")

Here's more info:
http://msdn.microsoft.com/library/d...mWebUIPageClassRegisterStartupScriptTopic.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Is there no way to do this serverside? I'd rather not have to go clientside
if I can at all avoid it.
 
C

csuttman

I had a consultant do some work and he used RegisterStartupScrip
throughout the site to pass javascript back to the page in order t
open a new window controlling size, menubar, etc. of it. PROBLEM is..
it puts javascript on the page that automatically opens this new windo
when the page loads... which pop-up blockers don't like. Pop-up blocker
don't block user initiated onClick events, but javascript that isn'
user controlled is blocked

We tried getting around it by openning dialogue windows instead o
window.open whic worked, except no menubar is shown.

I'm almost to the point to not open any windows from the site... whic
would really suck. I need to keep a main window open and open report
in additional windows. Sometimes multiple reports to compar
side-by-side. I really don't want to re-write the entire site to ge
windows to open either

Is there a way to open a new window after doing some processing serve
side that doesn't get blocked by pop-up blockers???

HELP!!! PLEASE!!! IT'S DRIVIN' ME NUTS!!


-
csuttma
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top