473,385 Members | 1,907 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,385 software developers and data experts.

New URL on the same window

I have a confirmation page with an OK button. If this window has an
opener then this browser window needs to go to another URL or else the
window must close.

Thus I have the following javascript to achieve the above which does
not work:
<script language="jscript">
function PageRedirection()
{
if(!opener)
{
//document.url("Search.aspx");
//location.replace("Search.aspx");
window.location.href = "Search.aspx";
}
else
{
window.close();
}
}
</script>
Can someone help???
Thanks in advance
Jul 20 '05 #1
8 15093
Lee
Renuka said:

I have a confirmation page with an OK button. If this window has an
opener then this browser window needs to go to another URL or else the
window must close.

Thus I have the following javascript to achieve the above which does
not work:
<script language="jscript">
function PageRedirection()
{
if(!opener)
{
//document.url("Search.aspx");
//location.replace("Search.aspx");
window.location.href = "Search.aspx";
}
else
{
window.close();
}
}
</script>
Can someone help???


What does "does not work" mean, precisely?
With the <script> tag corrected to:
<script type="text/javascript">
it works fine for me in several browsers.

Jul 20 '05 #2
The new URL which should open on th esame window does not work , to be
precise this exact line does not work:
window.location.href = "Search.aspx";

What works is the window.close() method.

Thanks
Renuka


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
Lee
Renuka Srivastava said:

The new URL which should open on th esame window does not work , to be
precise this exact line does not work:
window.location.href = "Search.aspx";

What works is the window.close() method.


That still doesn't tell me what you mean by "does not work".
Are there any error messages? Does it do nothing at all, or
does it seem to do the wrong thing?

Jul 20 '05 #4
I have a Confirmation.aspx page with an "OK" button. Once that button is
clicked it instantiates the javascript function on the clientside. If
this Confirmation.aspx has an opener the "OK" button should close the
browser window(which works properly), but when there is no opener the
"OK" button should open a different URL on the same window instead it
remains on the page Confirmation.aspx

window.location.href = "Search.aspx";

Hope I have made myself clear

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Lee
Renuka Srivastava said:

I have a Confirmation.aspx page with an "OK" button. Once that button is
clicked it instantiates the javascript function on the clientside. If
this Confirmation.aspx has an opener the "OK" button should close the
browser window(which works properly), but when there is no opener the
"OK" button should open a different URL on the same window instead it
remains on the page Confirmation.aspx

window.location.href = "Search.aspx";

Hope I have made myself clear


My best guess is that "Search.aspx" is not found.
Try specifying the complete URL.
Your code as written works just fine, if the specified URL exists.

Jul 20 '05 #6
Renuka wrote on 09 Dec 2003 at Tue, 09 Dec 2003 16:38:22 GMT:
I have a confirmation page with an OK button. If this window has
an opener then this browser window needs to go to another URL or
else the window must close.

Thus I have the following javascript to achieve the above which
does not work:
<script language="jscript">
You must use the type attribute: it is required by the HTML
specification. The language attribute is then usually not needed. The
above should read (assuming you're using JScript, and not
JavaScript):

<script type="text/jscript">
function PageRedirection()
{
if(!opener)
{
//document.url("Search.aspx");
//location.replace("Search.aspx");
window.location.href = "Search.aspx";
}
else
{
window.close();
}
}
</script>


Simple: remove the exclamation mark (!). Think about it...

A call to window.open() opens a new window (child), and sets the
window.opener property of the child to reference the parent's window
object (hope that made sense) [1]. If a window wasn't opened with a
window.open() call, window.opener is undefined or null (depending on
the browser). The former evaluates to true as a boolean, and the
latter as false:

if ( window.opener ) {
// Window opened with window.open()
} else {
// Window opened by some other means
}

What you have in your post is reversed, so when window.opener
references a window object, it closes the window rather than
redirecting it.

On a different note: I would advise that you fully qualify the opener
property. That is, use window.opener, not just opener.

Mike
[1] The first part of that sentence is /very/ important: the
window.opener property is set when window.open() is used to create
the window.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #7
Lee
Michael Winter said:

What you have in your post is reversed, so when window.opener
references a window object, it closes the window rather than
redirecting it.


Why do you assume that this isn't what the OP wants?
If this is not a child window, redirect to the new location.
If this is a child window, close it.

Jul 20 '05 #8
Lee wrote on 10 Dec 2003 at Wed, 10 Dec 2003 01:00:42 GMT:
Michael Winter said:

What you have in your post is reversed, so when window.opener
references a window object, it closes the window rather than
redirecting it.
Why do you assume that this isn't what the OP wants? If this is
not a child window, redirect to the new location. If this is a
child window, close it.


Umm, perhaps because the OP said that a child window (i.e.
non-null window.opener) should be redirected, whilst a window with
a null window.opener should be closed.

From the original post:
I have a confirmation page with an OK button. If this window has
an opener then this browser window needs to go to another URL or
else the window must close.


Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk")
Jul 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carol Lyn | last post by:
Could use your assistance with this. I have a window that opens via onclick and it is a small window with info about a site. If the user is interested in visiting that site, there is a link to...
2
by: Juan Garcia | last post by:
Subject says it all. Given: Window A with text field. Window B with a button (onClick opens Window C) Window C with a button (onClick I want it to modify text fields of Window A) I have...
6
by: David Hayes | last post by:
juglesh <juglesh@nospamRadioKDUG.com> wrote in "Re: how to maximize the browser window that fits the monitor size?" (Saturday, January 01, 2005 3:12 AM): > > >I want to maximize the browser...
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...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
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...
5
by: asadhkhan | last post by:
I have the following code which works correctly in IE 6, but in IE 7, Fire Fox 2.0 and Netscape 8 it does not work. I have a main page where a button calls this pop-up and uploads a file once you...
24
by: Jeremy J Starcher | last post by:
While reading c.l.j, I've noticed that some people prefer and indeed even recommend the use of "window.alert()" over "alert()". I can't find any technical reason to make this distinction, and...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.