473,387 Members | 1,722 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

window.open -- how to keep original page

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
5 2517
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
4
by: Dan Cruz | last post by:
Below are two files: Main.asp and Help.asp. I've stripped it down to the 'barest-of bones' so that anyone willing to help can duplicate the problem on their own systems. ***Main.asp*** looks...
19
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). ...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
2
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
3
by: hb | last post by:
Hi, I have a asp:button btnGo. When clicking this button, the code will parse a asp:table to find a specific ID under certain conditions. Once the ID is found, the code need to keep the current...
7
by: MrFez | last post by:
Through some investigation it appears that selecting "Every visit to the page" for the IE caching setting "Check for new version of stored pages" causes the window.opener property of child windows...
4
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.