473,769 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can anyone explain why this doesn't work?

I have an application that uses a window.open() to open it's own main window
where all my programs takes place. I use a timeout so if nothing goes on for
15 minutes the document below is called. To log in again all the users have
to do is to click the link in the lower part of the window. This causes the
login window to show up again. The problem arise if the window that opened
this window has been closed in the meantime. To deal with this and avoid the
top.window.open er is null or not an object error I made the startLogin
function. When the original top window has been closed the alert shows up
fine and thereby indicates that the program has reached that far, but the
document.locati on stuff doesn't work. Nothing happens. As you can see, I've
tried several different versions (and others too), but none of them seem to
work. Can anyone tell me what I'm doing wrong?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>Logged Out</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="Styles/StylesMenu.css" rel="stylesheet " type="text/css">
<script type=text/javascript>
function startLogin(){
if (top.window.ope ner){
top.window.open er.location="De fault.htm";
top.window.clos e();
}
else {
alert("It get's to this point and then nothing more happens!");
self.document.l ocation="Defaul t.htm";
self.document.l ocation.href("D efault.htm");
document.locati on="Default.htm ";
location="Defau lt.htm";
}
}
</script>

</head>

<body onload="javascr ipt:window.stat us='The system logged you out!'">
<form>
<table align="center" border="0">
<tr>
<td><div align="center"> <img border="6" src="images/Trwww2.gif"
ALIGN="MIDDLE"> </div>
</td>
</tr>
</table>
<h1 align="center"> You are logged out!</h1>
</p>
<div align="center"> <font size="2"><a href="javascrip t:void(0);"
onclick="startL ogin();">Log in again</a></font></div>
</form>
</body>
</html>

Thanks for any help!
iv**@tda.no
Jul 23 '05 #1
4 9514
In article <pj************ ******@news2.e. nsc.no>, iv**@tda.no enlightened us
with...
Can anyone tell me what I'm doing wrong?
Classic mistake.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
Um, quirks mode?
Just an aside. Nothing to do with the error.
else {
alert("It get's to this point and then nothing more happens!");
self.document.l ocation="Defaul t.htm";


You just changed the location of the current document. Therefore, no more
script is present to execute (unless there's some in default.htm), as it got
wiped out by the new page.
--
--
~kaeli~
Can you be a closet claustrophobic?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #2
else {
alert("It get's to this point and then nothing more >>happens!");
self.document.l ocation="Defaul t.htm";
You just changed the location of the current document. >Therefore, no morescript is present to execute (unless there's some in >default.htm) , as it gotwiped out by the new page.


but although I set self.document.l ocation to Default.htm, Default.htm
never shows up in the browser! Shouldn't the current window at least
show Default.htm? It doesn't. That is the problem I wanted help with ;-)

Brgds
Iv**@tda.no

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #3
In article <41************ **********@news .newsgroups.ws> , iv**@tda.no
enlightened us with...
else {
alert("It get's to this point and then nothing more >>happens!");
self.document.l ocation="Defaul t.htm";

You just changed the location of the current document. >Therefore, no

more
script is present to execute (unless there's some in >default.htm) , as

it got
wiped out by the new page.


but although I set self.document.l ocation to Default.htm, Default.htm
never shows up in the browser! Shouldn't the current window at least
show Default.htm? It doesn't. That is the problem I wanted help with ;-)


Then the line is erroring out, more than likely.

Try using one of these instead.
Why are you using top.window.open er? Is this a frameset or iframe? If not,
you can probably ditch top for cleaner code. 'top' is a window object. I
don't see the need for 'top.window'. Either use top.opener or just opener.

I don't have your whole code, so check these two versions out and use the one
that works for you.

#1:
Assumes the window running this is a frameset or in an iframe:
if (top.opener){
top.opener.loca tion="Default.h tm";
top.close();
}
else {
top.document.lo cation.href = "Default.ht m"; /* use if entire frameset
should go to default */
// self.document.l ocation.href = "Default.ht m"; /* use this one if only the
current doc should go */
}

'top' would reference the upper-most window object. If a multi-layer
frameset, you may need 'parent' instead.

#2:
Assumes this code is running from a popup that is not part of a frameset:
if (self.opener){
self.opener.loc ation="Default. htm";
self.close();
}
else {
self.document.l ocation.href = "Default.ht m";
}

Location is technically an object. href is the property to set.

Also, this code is redundant.
<body onload="javascr ipt:window.stat us='The system logged you out!'">

onload is by its very nature a script event.
<body onload="window. status='The system logged you out!'">
Note that some browsers allow users to disable changing of status bar text.

Also, this isn't cool, either.
<div align="center"> <font size="2"><a href="javascrip t:void(0);"
onclick="startL ogin();">Log in again</a></font></div>

An anchor is just that - an anchor that when clicked goes to some other
document or a place in the current document (or it names a place in a
document). In newer browsers, there is just no need to pretend it's a link
when it's really more of a button (it doesn't go anywhere - it calls a script
function). NN4 didn't support div onClick, so people got used to using
anchors to do things that they really weren't intended to do.
If you want to really do it the right way, you use a real button and style it
with CSS to look like whatever you want (you can make it look like a text
link if you desire).

So, if this is an internet app and you don't know what your users have, use:
<div align="center"> <font size="2"><a href="someNonJS page.htm"
onclick="startL ogin();return false;">Log in again</a></font></div>

If this is intranet and you have to support NN4, you can use the above or
use:
<div align="center"> <font size="2"><a href="#"
onclick="startL ogin();return false;">Log in again</a></font></div>

The 'return false' prevents the link from being followed when the function is
done being run.

If this is intranet and your users have modern browsers, NN6+/IE5
+/Mozilla/Opera6+, use:
<div align="center"> <font size="2"><div onclick="startL ogin();">Log in again
</div></font></div>
(name and style div as desired)

or:

<div align="center"> <input type="button" value="Log In Again"
onClick="startL ogin()"></div>
(again, style as desired)

HTH

--
--
~kaeli~
You can't have everything. Where would you put it?
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 23 '05 #4
Thanks a lot for taking the time to help me!

IVer
Jul 23 '05 #5

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

Similar topics

8
10478
by: Bo Wisén | last post by:
Hi, A project in VB6 recently worked without any problems but now it's complaining when I try to use 'Right$'. In immediate mode, when I'm typing 'print left$("123456",2)' I get the correct result '12'. When I type 'print right$("123456",2) I expect the result '56' but all I get is an error 'type declaration does not match declared data type'. And I can't find that I have tried to declare 'right'. Can anyone explain what can cause this...
1
1949
by: Jinlin | last post by:
I found a interesting problem in C# and couldn't explain it. The code to reproduce it is very simple: 1. Create a windows application in C#. 2. Listen to the activated event on the default form --- Form1.cs 3. Create a method DoUpdate() which will popup two dialog boxes "Dialog box one" and "Dialog box two". 4. Call DoUpdate() in the activated event handling. It will look like the following:
13
2471
by: C++fan | last post by:
The following code is for list operation. But I can not understand. Could anyone explain the code for me? /* * List definitions. */ #define LIST_HEAD(name, type) struct name { type *lh_first; /* first element */
3
3709
by: Robert A. van Ginkel | last post by:
In news:OZ0W9RsdDHA.2432@TK2MSFTNGP10.phx.gbl... I ask the question how I can see if all the data is on the other side of the connection. I got as answer that I should use the blocking property. I tried this I don't see any diffents, I am sending 10Mb and the Send/BeginSend command doesn't wait till the data is on the remotepoint. Can somebody pls. explain this. Regards Robert.
5
2729
by: tony | last post by:
I'm using PHP 5 on Win-98 command line (ie no web server involved) I'm processing a large csv file and when I loop through it I can process around 275 records per second. However at around 6,000 records this suddenly drops off to around 40 records per second. This is a big problem as the "live" list is over 4 million records long. I'd break it up but this is to be a regular test so that would be messy
2
1978
by: PleegWat | last post by:
Hi, I'm using this function: function die_quietly( $text='', $title='', $file='', $line='', $sql='' ) { global $wowdb, $roster_conf, $wordings, $roster_menu; // die_quitely died quietly if (defined(ROSTER_DIED))
6
2129
by: MZ | last post by:
Hello! The following js code doesn`t work fine on Firefox and I don`t know why. I have table with 30 rows and on IE I click once on analyse button and it fills my cells automaticaly, but when I click the same analyse button on Firefox it fills me only one row and force me to click 30 times to fill the whole table. I replaced js break; into js continue; but it didn`t help me.
1
2009
Eclipse
by: Eclipse | last post by:
G'day all Can anyone explain the difference in the results to me as I don't understand why specifying the directory name in two different ways could give a different answer. In CODE 1 below i specified the directory path in the code. In CODE 2 below i specified the directory path through a wxPython dialog. When I run CODE 1 I get the following:
1
2684
by: windscar | last post by:
Hello Everybody! I am a beginner that try to learn C++ programming. I work in Linux Ubuntu Karmic Koala (9.10) environment. I got a problem with getchar(). The function works well in a simple program. But when I use it in while (cond.) and switch (var.) , the function doesn't work, it doesn't even ask me to input character (including "\n"). Or maybe there are other reasons why getchar() doesn't work. I am sorry if I repost the same...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.