By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,071 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

window.open -- how to keep original page

P: n/a
Hello,

I have a link on an aspx page. The URL is set in the Page Load event:

lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "')"

When I click the link, the new window opens as expected. The problem is
that on the original page containing the link, everything disappears and is
replaced with just this:

[object]

Can anyone tell me why this is happening and how I can keep the original
page intact while popping up the new window?

Thanks very much.
Nov 19 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Output a standard HTML anchor tag with the Target attribute specified.
<a href="EventHistory.aspx" target='_blank'>click me</a>

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

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
Hello,

I have a link on an aspx page. The URL is set in the Page Load event:

lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "')"

When I click the link, the new window opens as expected. The problem is
that on the original page containing the link, everything disappears and
is
replaced with just this:

[object]

Can anyone tell me why this is happening and how I can keep the original
page intact while popping up the new window?

Thanks very much.

Nov 19 '05 #2

P: n/a
Thank you for your reply. I'm still wrestling with this. Let me give some
more background.

I tried two things based on your suggestion:

1) I created a label on the form. On the Page Load event, I set the text of
the label to this:

lblEventHistoryLink.Text = "<a href='EventHistory.aspx?TeenID=" &
Request.Item("SubjectID") & "&EventCode=" & Request.Item("EventCode") & "'
target='_blank'>View Event History</a>"

This sort of worked, except that I need to use Javascript's window.open
method so that I can set the new window's size, menubars, etc.

2) Second thing I tried -- On my original hyperlink, which is an ASP Web
control, I set the Target to "_blank" in the Properties window. When I run
it and click the link, I get two new windows:

- The first is a blank page that has the text "[object]" in it. The
address bar says:
javascript:window.open('EventHistory.aspx?TeenID=1 23&EventCode=10')

- The second window is the page that I actually want.

Is there any way to get rid of this intermediate "[object]" window?

Any other ideas I can try?

Thanks.

"Steve C. Orr [MVP, MCSD]" wrote:
Output a standard HTML anchor tag with the Target attribute specified.
<a href="EventHistory.aspx" target='_blank'>click me</a>

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

"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:8C**********************************@microsof t.com...
Hello,

I have a link on an aspx page. The URL is set in the Page Load event:

lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "')"

When I click the link, the new window opens as expected. The problem is
that on the original page containing the link, everything disappears and
is
replaced with just this:

[object]

Can anyone tell me why this is happening and how I can keep the original
page intact while popping up the new window?

Thanks very much.


Nov 19 '05 #3

P: n/a
I just tried a third idea. I added the window.open to the href in the
standard HTML anchor, like this:

Dim strhref As String
strhref = "javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("TeenID") & "&EventCode=" &
Request.Item("EventCode") & "')"
lblEventHistoryLink.Text = "<a href=""" & strhref & """
target=""_blank"">View Event History</a>"

I'm getting the same behavior as with the ASP Web control hyperlink -- an
intermediate window containing only the text "[object]" opens in addition to
the final desired window.

So I don't think the problem is with the standard HTML anchor versus the ASP
Web control hyperlink. There must be some subtlety of Javascript that I am
missing.

Can anyone help me?
"Chris" wrote:
Hello,

I have a link on an aspx page. The URL is set in the Page Load event:

lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "')"

When I click the link, the new window opens as expected. The problem is
that on the original page containing the link, everything disappears and is
replaced with just this:

[object]

Can anyone tell me why this is happening and how I can keep the original
page intact while popping up the new window?

Thanks very much.

Nov 19 '05 #4

P: n/a
You need to execute two lines of javascript:

Window.Open(...);
Document.location='page2.aspx';

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:12**********************************@microsof t.com...
I just tried a third idea. I added the window.open to the href in the
standard HTML anchor, like this:

Dim strhref As String
strhref = "javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("TeenID") & "&EventCode=" &
Request.Item("EventCode") & "')"
lblEventHistoryLink.Text = "<a href=""" & strhref & """
target=""_blank"">View Event History</a>"

I'm getting the same behavior as with the ASP Web control hyperlink -- an
intermediate window containing only the text "[object]" opens in addition
to
the final desired window.

So I don't think the problem is with the standard HTML anchor versus the
ASP
Web control hyperlink. There must be some subtlety of Javascript that I
am
missing.

Can anyone help me?
"Chris" wrote:
Hello,

I have a link on an aspx page. The URL is set in the Page Load event:

lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "')"

When I click the link, the new window opens as expected. The problem is
that on the original page containing the link, everything disappears and
is
replaced with just this:

[object]

Can anyone tell me why this is happening and how I can keep the original
page intact while popping up the new window?

Thanks very much.

Nov 19 '05 #5

P: n/a
Hello Chris,
lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "'); return false"
Note the addition of the 'return false'. This instructs the browser to stop
processing.

--
Matt Berther
http://www.mattberther.com
Hello,

I have a link on an aspx page. The URL is set in the Page Load event:

lnkEventHistory.NavigateUrl =
"javascript:window.open('EventHistory.aspx?TeenID= " & _
Request.Item("SubjectID") & "&EventCode=" &
Request.Item("EventCode") & "')"
When I click the link, the new window opens as expected. The problem
is that on the original page containing the link, everything
disappears and is replaced with just this:

[object]

Can anyone tell me why this is happening and how I can keep the
original page intact while popping up the new window?

Thanks very much.

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.