471,092 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

what's wrong??!?!?!

tin

<script language="Javascript">
<!--
function apri (theURL,winName,features){
window.open (theURL,winName,features);
var a=null;
oldwindow = window.self;
oldwindow.opener = window.self;
oldwindow.close();
}
-->
</script>
<A
href=javascript:apri('../pagine_popup/page_to_load.html','finestra1','width=
220,height=260','scrollbars=no')>start</a>
i wanna close the old page ONLY when i click on the link which open a new
page.
What's wrong? please help me :)

daniele
Jul 20 '05 #1
5 1723
"tin" <pa****@panservice.it> writes:
i wanna close the old page ONLY when i click on the link which open a new
page.
What's wrong? please help me :)
You tell me! What *is* wrong?

To get qualified help, you need to tell us:
1) What are you doing (inluding which browser you are using).
2) What you expect to happen.
3) What really happens.

You failed to provide the third piece of information, so we have to
run it ourselves and see what happens. Since we don't know which browser
you are using, we might not get the same error.

What error message does your browser give? Mine said something about
an unterminated string literal. That is usually because a string has
been broken onto two lines.
<script language="Javascript">
<!--
function apri (theURL,winName,features){
window.open (theURL,winName,features);
var a=null;
oldwindow = window.self;
oldwindow.opener = window.self;
oldwindow.close();
}
-->
</script>
This script looks operable. A more correct version would be:

<script type="text/javascript">
function apri(theUrl,winName,features) {
window.open(theUrl,winName,features);
window.opener = window;
window.close();
}
</script>

You should know that this script abuses a bug in IE that allows you to
close a browser window that was not opened by the page. That is a bad
thing to do, and can make users very angry. It might also get fixed in
a later version of the browser.
<A
href=javascript:apri('../pagine_popup/page_to_load.html','finestra1','width=
220,height=260','scrollbars=no')>start</a>


This is incorrect HTML. Attributes containing anything except
alphanumeric characters and a few select elements of punctuation
*must* be quoted.

You should also avoid using the javascript: pseudo protocol.
<URL:http://jibbering.com/faq/#FAQ4_24>
It has potential side effects that you avoid in *this* case, but it is
a bad habit to get. Use the onclick attribute instead. Also notice
that you pass four arguments to a function that only uses three.

<a href="noJS.html"
onclick="apri('../pagine_popup/page_to_load.html','finestra1',
'width=220,height=260,scrollbars=no,resizable=yes' );">
start</a>

If you remove the scrollbars, you should *alway* make the window
resizable. Otherwise, content might be placed outside the visible area
with no way to get to it. Remember that you cannot control the font size
of the users browser if he choses to override it.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
tin
my browser is IE5.5
3) What really happens.

two new pages appear because i used your code:

<a href ="noJS.html"

onclick="apri('../pagine_popup/page_to_load.html','finestra1','width=220,hei
ght=260,resizable=yes');">
start</a>

and the IE try to open two page: nojs.htm and page_to_load.html but i need
the one opened with the onclick
the old page doesn't close because the link is placed on the center of a
framed page. So i need to close all the frame. How can i do this?
I didn't do the graphical job. That's why i didn't knew that it is a framed
page.

thanks
Jul 20 '05 #3
"tin" <pa****@panservice.it> writes:
my browser is IE5.5
3) What really happens. two new pages appear because i used your code:


Ah, yes. If the closing of the window fails, that would be the effect.
<a href ="noJS.html"

onclick="apri('../pagine_popup/page_to_load.html','finestra1','width=220,hei
ght=260,resizable=yes');">
To prevent the noJS.html file from opening (in which you explain why
your page requires Javascript to work), you add "return false" to the
end of the onclick attribute value. That cancels the click so the href
isn't opened.
and the IE try to open two page: nojs.htm and page_to_load.html but i need
the one opened with the onclick the old page doesn't close because the link is placed on the center of a
framed page.
That explains why it doesn't close.
So i need to close all the frame. How can i do this?


Change the lines:
window.opener = window;
window.close();
to
top.opener=top;
top.close();
That should close the entire frameset.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #4
tin
everithing is working
thanks

"Lasse Reichstein Nielsen" <lr*@hotpop.com> ha scritto nel messaggio
news:ek**********@hotpop.com...
"tin" <pa****@panservice.it> writes:
my browser is IE5.5

Jul 20 '05 #5
In article <r8**********@hotpop.com>, Lasse Reichstein Nielsen <lr*@hotpop.com>
writes:
You should know that this script abuses a bug in IE that allows you to
close a browser window that was not opened by the page. That is a bad
thing to do, and can make users very angry. It might also get fixed in
a later version of the browser.


Contrary to beliefs, its not a bug that is limited to IE. It is very
widespread, in many browsers, in some form or another. Whether its closing the
window or closing an active tab in tabbed browsers.
--
Randy
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

72 posts views Thread by E. Robert Tisdale | last post: by
121 posts views Thread by typingcat | last post: by
28 posts views Thread by Madhur | last post: by
46 posts views Thread by Keith K | last post: by
13 posts views Thread by Jason Huang | last post: by
9 posts views Thread by Pyenos | last post: by
3 posts views Thread by Siong.Ong | last post: by

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.