472,982 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

popup open problem only with firefox

Hi,

i have this problem:

Sometimes, i can't reproduce, if i click on an small image on the
website, the popup _AND_ an other Tab in firefox open.

Here are the linkcode:

<div align="center">
<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"
onclick="popup(this, 850, 800); return false" target="_blank"><img
class="newspic_click" src="/newspics/p4_7ghz_memesama.jpg" alt="Bild"
title="Zum vergrößern klicken"></a>
</div>

Where? http://www.tweakpc.de/?news_id=8100 here for example

Why can this happen ? I have tried a lot, but nothing works.

--
Markus K.

Aug 11 '05 #1
23 6318
ASM
Markus wrote:
Hi,

i have this problem:

Sometimes, i can't reproduce, if i click on an small image on the
website, the popup _AND_ an other Tab in firefox open.
your code in my FF (where I allow to open popups send from links)
open two new blank pages ... ! (and no other tab)
one naked and one complete
Here are the linkcode:

<div align="center">
<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"
onclick="popup(this, 850, 800); return false" target="_blank"><img
class="newspic_click" src="/newspics/p4_7ghz_memesama.jpg" alt="Bild"
title="Zum vergrößern klicken"></a>
</div>
what does exactly your function popup() ?
what is 'this' for the function popup() in :
onclick="popup(this, 850, 800); ?
Where? http://www.tweakpc.de/?news_id=8100 here for example

Why can this happen ? I have tried a lot, but nothing works.


function popup(lnk,wiz,higt) {
here=window.open(lnk.href,'here','width='+wiz+',he ight='+higt+',resizable=1');
//------------------------^----^ here = the target
}

<a href="big.jpg" target="here" onclick="popup(this,850,screen.height-40)">

will open the page hrefered in links in a new naked window targeted
with same name as called in link ( target -> 'here' )
So ... no need of 'return false'

If JS is disabled, that will open a blank standard window

If popups are disabled in FF, I hope that it will open a new tab ... (?)

--
Stephane Moriaux et son [moins] vieux Mac
Aug 11 '05 #2
ASM wrote:
your code in my FF (where I allow to open popups send from links)
open two new blank pages ... ! (and no other tab)
one naked and one complete
Did you checked the link i posted in my first entry ? There is link to
a news with a small image that can be enlarged by clicking the picture.
What happend on your PC?
Here are the linkcode:

<div align="center">
<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"
onclick="popup(this, 850, 800); return false" target="_blank"><img
class="newspic_click" src="/newspics/p4_7ghz_memesama.jpg" alt="Bild"
title="Zum vergrößern klicken"></a>
</div>


what does exactly your function popup() ?
what is 'this' for the function popup() in :
onclick="popup(this, 850, 800); ?


ok i forgot to insert the hole Script. Here it is:

function popup(element, width, height) {
if (element.getAttribute) {
url = element.getAttribute('href');
} else {
url = element;
}
new_window = window.open(url, '_blank', 'width=' + width + ', height='
+ height + ', left=' + Math.round((screen.width - width)/2) + ', top='
+ Math.round((screen.height - height)/4) + ', location=0, statusbar=0,
menubar=0, toolbar=0, scrollbars=1, resizable=yes');
}

If Javascript is enabled it should be there one new window with witdh
of 850 and height of 800. And if javascript disabled the big picture
should be open in an fresh ne window (target="_blank").
<a href="big.jpg" target="here" onclick="popup(this,850,screen.height-40)">

will open the page hrefered in links in a new naked window targeted
with same name as called in link ( target -> 'here' )
So ... no need of 'return false' Dont understand ? the part _return false_ is used if javascript is
enabled to prevent the browser to open the new site in an extra new
full window.
If JS is disabled, that will open a blank standard window

yes.

Ok i hope now its clear.

Aug 12 '05 #3
ASM
Markus wrote:

Did you checked the link i posted in my first entry ?
I did this :
http://www.tweakpc.de/?news_id=8100
link :
<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"
onclick="popup(this, 900, 800); return false" target="_blank"><img
class="newspic_click" src="/newspics/p4_7ghz_memesama.jpg" alt="Bild"
title="Zum vergr&ouml;&szlig;ern klicken" /></a>
What happend on your PC?
I have a Mac :-/
and obtain 2 new windows (with big jpg and some moving decorations)
one in "normal" blank
other by window.open()
ok i forgot to insert the hole Script. Here it is:

function popup(element, width, height) {
if (element.getAttribute) {
url = element.getAttribute('href');
} else {
url = element;
}
new_window = window.open(url, '_blank', 'width=' + width + ', height='
+ height + ', left=' + Math.round((screen.width - width)/2) + ', top='
+ Math.round((screen.height - height)/4) + ', location=0, statusbar=0,
menubar=0, toolbar=0, scrollbars=1, resizable=yes');
}
it is status and not statusbar
try to do not have spaces in the attributes of window.open()
If Javascript is enabled it should be there one new window with witdh
of 850 and height of 800. And if javascript disabled the big picture
should be open in an fresh ne window (target="_blank").
It seems it would have to ...
Perhaps, if you could try giving same target (as you do)
- to the link
- to the window.open()
but with a real name insteed of "_blank" (i.e : "somewhere")

It also would be interresting you see what exactly does :
screenshot?show=
with same name as called in link ( target -> 'here' )
So ... no need of 'return false'


Dont understand ? the part _return false_ is used if javascript is
enabled to prevent the browser to open the new site in an extra new
full window.


Yes usualy, but you use "_blank" as target in your popup ...
try without target in your popup function :
new_window = window.open(element.href,'',' blah blah ');

and ... I made a mistake :
to do not have blank window AND popup you would have to do :

function popup(width,height) {
new_window = window.open('','truc','width=' + width + ',height='
+ height + ', left=' + Math.round((screen.width - width)/2) + ',top='
+ Math.round((screen.height - height)/4) +
',location=0,status=0,menubar=0,toolbar=0,scrollba rs=1,resizable=1');
}

and your link would have to be :

<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"

target="truc"

onclick="popup(850,800)"><img src=" ...></a>

If JS is disabled, that will open a blank standard window

Ok i hope now its clear.


your post was clear

the JS result of your link not too much :-/

my example (based on your JS) is here :
http://perso.wanadoo.fr/stephane.moriaux/truc/popup.htm
(it works fine with my FF)

--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #4
ASM wrote:
I have a Mac :-/ sorry! ;) I forgot to check it on my one. Primary i use a pc.
It also would be interresting you see what exactly does :
screenshot?show= This php file only build the entire popup website with the image of the
php paramter.
to do not have blank window AND popup you would have to do :

function popup(width,height) {
new_window = window.open('','truc','width=' + width + ',height='
+ height + ', left=' + Math.round((screen.width - width)/2) + ',top='
+ Math.round((screen.height - height)/4) +
',location=0,status=0,menubar=0,toolbar=0,scrollba rs=1,resizable=1');
}

and your link would have to be :

<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"

target="truc"

onclick="popup(850,800)"><img src=" ...></a>
if (element.getAttribute) {
url = element.getAttribute('href');
} else {
url = element;
}


GREAT it works!, but what happened to my elemt.get... code ? Can't
understand why there is no need for. How the browser know, witch File
he have to open ?
my example (based on your JS) is here :
http://perso.wanadoo.fr/stephane.moriaux/truc/popup.htm
(it works fine with my FF)


Thank you very much! Wow what a result of a long day. Just entered the
google-groups and posted a question, and hours later i have the answer
i searching since days :)
ok gn8 (4:15 am)

Aug 12 '05 #5
There is one probleme now: It don't work with IE :(. Now, i have to
find a solution.

Aug 12 '05 #6
Markus wrote:
There is one probleme now: It don't work with IE :(. Now, i have to
find a solution.

Read the thread here:

<URL:http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/caf4e95379da303f/819e9b8f438e7faa?q=target%3D_blank+opens+two&rnum= 1&hl=en#819e9b8f438e7faa>

--
Rob
Aug 12 '05 #7
Markus a écrit :
ASM wrote:

your code in my FF (where I allow to open popups send from links)
open two new blank pages ... ! (and no other tab)
one naked and one complete

Did you checked the link i posted in my first entry ? There is link to
a news with a small image that can be enlarged by clicking the picture.
What happend on your PC?

Here are the linkcode:

<div align="center">
<a href="/screenshot?show=p4_7ghz_memesama_big.jpg"
onclick="popup(this, 850, 800); return false" target="_blank">
You can avoid the forking in the popup function by making
onclick="popup(this.href, 850, 800); return false;"
instead

<imgclass="newspic_click" src="/newspics/p4_7ghz_memesama.jpg" alt="Bild"
title="Zum vergrößern klicken"></a>
</div>


what does exactly your function popup() ?
what is 'this' for the function popup() in :
onclick="popup(this, 850, 800); ?

ok i forgot to insert the hole Script. Here it is:

function popup(element, width, height) {
if (element.getAttribute) {
url = element.getAttribute('href');
} else {
url = element;
}
new_window = window.open(url, '_blank', 'width=' + width + ', height='
+ height + ', left=' + Math.round((screen.width - width)/2) + ', top='
+ Math.round((screen.height - height)/4) + ', location=0, statusbar=0,
menubar=0, toolbar=0, scrollbars=1, resizable=yes');

1- new_window should be properly declared as a global variable
2- you can replace '_blank' with a parameter transferring, copying the
target attribute value. This makes your function better parameterized,
reusable.
3- there must not be any blank space in the windowFeatures string list.
Here, you have one between each of the commas and the following name of
the windowFeature. This will break in Firefox and other Mozilla-based
browsers.
4- because of your blank spaces, scrollbars and resizable requests of
the window.open() call will be ignored
5- You request an height of 800px: that will fail in a very wide
majority of cases because a majority of 1024x768 users have about 660px
or less of available space for a window. So not only the window's top
will be reset by Mozilla/Firefox compensating positioning code, but your
window will not be 800 either.
6- do not use screen.width in any of your calculation; use
screen.availWidth and screen.availHeight since you have no idea of what
the user has in terms of semi-permanent os-dependent applications
(taskbar, MS-Magnification, Office quick launch bar, etc)
7- you make your call calculate top and left position but for
efficiency, best is to use a percentage of screen.availWidth and
screenAvailHeight
8- Hint: only declare the windowFeatures which are requested, not the
ones you want to turn off, to disable
http://developer.mozilla.org/en/docs....open#Examples
}

If Javascript is enabled it should be there one new window with witdh
of 850 and height of 800. And if javascript disabled the big picture
should be open in an fresh ne window (target="_blank").

If you want a complete, recommendable and working example, use this document

http://developer.mozilla.org/en/docs/DOM:window.open

and this example

http://developer.mozilla.org/en/docs...Best_practices

<a href="big.jpg" target="here" onclick="popup(this,850,screen.height-40)">

will open the page hrefered in links in a new naked window targeted
with same name as called in link ( target -> 'here' )
So ... no need of 'return false'
Dont understand ? the part _return false_ is used if javascript is
enabled to prevent the browser to open the new site in an extra new
full window.


Correct.
If JS is disabled, that will open a blank standard window


yes.

Ok i hope now its clear.


Gérard
--
remove blah to email me
Aug 12 '05 #8
ASM
Markus wrote:
ASM wrote:
It also would be interresting you see what exactly does :
screenshot?show=
This php file only build the entire popup website with the image of the
php paramter.


ok
GREAT it works!, but what happened to my elemt.get... code ? Can't
understand why there is no need for. How the browser know, witch File
he have to open ?


it is almost a standard html :

<a href="big.jpg" target="what_you_want">

will open file 'big.jpg' in the specified target

where is this target 'what_you_want' ?
in the window of popup launched on click ...

so ... what browser will do ?

... apply basically what it is made to :-)
If JS disabled, 'what_you_want' is unknown.
Because target is not '_self' nor '_top' or '_parent'
... no other choice than to create a new blank window
to receive the file
--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #9
ASM
Markus wrote:
There is one probleme now: It don't work with IE :(. Now, i have to
find a solution.


stil on Mac ... with :
- IE5.2 -> OK

- Opera 8.0.1
- Safari
- iCab 3.0
- etc ...
... all OK

what's wrong with your IE ?

--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #10
ASM
RobG wrote:
Markus wrote:
There is one probleme now: It don't work with IE :(. Now, i have to
find a solution.


Read the thread here:

<URL:http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/caf4e95379da303f/819e9b8f438e7faa?q=target%3D_blank+opens+two&rnum= 1&hl=en#819e9b8f438e7faa>


witch part of the thread ?
and what in this part ?

--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #11
ASM wrote:
RobG wrote:
Markus wrote:
There is one probleme now: It don't work with IE :(. Now, i have to
find a solution.

Read the thread here:

<URL:http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/caf4e95379da303f/819e9b8f438e7faa?q=target%3D_blank+opens+two&rnum= 1&hl=en#819e9b8f438e7faa>


witch part of the thread ?


The broomstick riding part ;-)
and what in this part ?


The thread discusses opening links in a new window so that if
JavaScript is available it will be used, and if not, then the default
HTML method is used. I didn't want to waste time re-writing stuff
that was covered just a couple of days ago.

It's difficult to tell from this thread exactly what the OP's issue
is, I figured a bit of further reading may help.

--
Rob
Aug 12 '05 #12
ASM
RobG wrote:
ASM wrote:
RobG wrote:
<URL:http://groups-beta.google.com/group/comp.lang.javascript/browse_frm/thread/caf4e95379da303f/819e9b8f438e7faa?q=target%3D_blank+opens+two&rnum= 1&hl=en#819e9b8f438e7faa>
and what in this part ?


It's difficult to tell from this thread exactly what the OP's issue is,


It is only because in this thread was overall exposed the "return false"
that I don't use in my example :
http://perso.wanadoo.fr/stephane.moriaux/truc/popup.htm
and that seems to do not work with IE Win (I can't verify on my Mac)
Really doesn't it work with IE6 Win xp?
I figured a bit of further reading may help.


Certainly.
In original post (here) the test url had a 'return false' without effect
http://www.tweakpc.de/?news_id=8100
curious ... no ?
--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #13
Hi Guys !

It works now. I found a solution and here it is:

Step 1: (inside header of website)
=====

Here is the part why ASM solution works sometimes and sometimes not:
In HEAD of my page i found this:

false
<script language="javascript" src="myscript.js"></script>

BUT true is:
<script type="text/javascript" language="javascript1.4"
src="/scripts/js/tweakpc.js"></script>

First mistake -> fixed!

Step 2: (inside mysript.js)
=====

Now i use the Code from Stephane. Thx again.

function popup(width,height)
{
new_window = window.open('','popup','width=' + width + ',height=' +
height + ', left=' + Math.round((screen.width - width)/2) + ',top=' +
Math.round((screen.height - height)/4) +
',location=0,status=0,menubar=0,toolbar=0,scrollba rs=1,resizable=1,');
return false;
}

2nd mistake -> fixed too!

Step3: (insite conted of website)
=====

The right linkcode is:

<div align="center">
<a href="/screenshot?show=macosx_intel_big.gif" target="popup"
onclick="popup(this, 900, 800); return false">
<img class="newspic_click_center" src="/newspics/macosx_intel.gif"
alt="Bild" title="Zum vergrößern klicken">
</a>
</div>

3rd mistake -> fixed too!

The summary
==========

It works fine at Mac OS X Tiger with Mozilla Firefox 1.0.6 and Safari
and at Windows XP with Mi****t Internet Explorer 6 and Mozilla Firefox
1.0.6.

Aug 12 '05 #14
ASM
Markus wrote:
The right linkcode is:

<div align="center">
<a href="/screenshot?show=macosx_intel_big.gif" target="popup"
onclick="popup(this, 900, 800); return false">
don't understand :
scripted function is different from called function
function popup(width,height) { }
onclick="popup(this, 900, 800);
<img class="newspic_click_center" src="/newspics/macosx_intel.gif"
alt="Bild" title="Zum vergrößern klicken">
</a>
</div>


--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #15

ASM wrote:
Markus wrote:
The right linkcode is:

<div align="center">
<a href="/screenshot?show=macosx_intel_big.gif" target="popup"
onclick="popup(this, 900, 800); return false">


don't understand :
scripted function is different from called function
function popup(width,height) { }
onclick="popup(this, 900, 800);


oh, sorry. my mstake. That was an old code. The present code have no
_this_.

thx.

Aug 12 '05 #16
Gérard Talbot wrote:
1- new_window should be properly declared as a global variable done
2- you can replace '_blank' with a parameter transferring, copying the
target attribute value. This makes your function better parameterized,
reusable. done
3- there must not be any blank space in the windowFeatures string list.
Here, you have one between each of the commas and the following name of
the windowFeature. This will break in Firefox and other Mozilla-based
browsers.
4- because of your blank spaces, scrollbars and resizable requests of
the window.open() call will be ignored done
5- You request an height of 800px: that will fail in a very wide
majority of cases because a majority of 1024x768 users have about 660px
or less of available space for a window. So not only the window's top
will be reset by Mozilla/Firefox compensating positioning code, but your
window will not be 800 either. This size will be ok. Our visitors have this huge resolution. We see
that on our stats.
6- do not use screen.width in any of your calculation; use
screen.availWidth and screen.availHeight since you have no idea of what
the user has in terms of semi-permanent os-dependent applications
(taskbar, MS-Magnification, Office quick launch bar, etc) done
7- you make your call calculate top and left position but for
efficiency, best is to use a percentage of screen.availWidth and
screenAvailHeight Can you give me an example ? The new code is at the end of this posting
8- Hint: only declare the windowFeatures which are requested, not the
ones you want to turn off, to disable done
If you want a complete, recommendable and working example, use this document
http://developer.mozilla.org/en/docs/DOM:window.open

Thanks very much! :)

==========
Code start

var new_window = null;
var url = null;
function popup(element, width, height)
{
if (new_window == null || new_window.closed )
{
if (element.getAttribute)
{
url = element.getAttribute('href');
}
else
{
url = element;
}
new_window = window.open(url, 'tpc', 'width=' + width + ', height='+
height + ', left=' + Math.round((screen.availWidth - width)/2) + ',
top=' + Math.round((screen.availHeight - height)/4) +
',scrollbars=1,resizable=yes');
return false;
}
else
{
new_window.focus();
return false;
}
}

Code end
========

Aug 12 '05 #17
ASM
Markus wrote:

The new code is at the end of this posting

==========
Code start

var new_window = null;
var url = null;
function popup(element, width, height)
{
if (new_window == null || new_window.closed )
// you must firstable close the popup if it is open

if (new_window != null || !new_window.closed)
new_window.close();
else
{
if (element.getAttribute)
if (element.getAttribute && element.getAttribute('href'))
or (I prefer) :
if(element.href)
{
url = element.getAttribute('href');
url = element.href;
}
else
{
url = element;
}
new_window = window.open(url, 'tpc', 'width=' + width + ', height=' +
height + ', left=' + Math.round((screen.availWidth - width)/2) + ',
top=' + Math.round((screen.availHeight - height)/4) +
',scrollbars=1,resizable=yes');
Please : without space

new_window = window.open(url,'tpc','width=' + width +
',height=' + height +
',left=' + Math.round((screen.availWidth - width)/2) +
',top=' + Math.round((screen.availHeight - height)/4) +
',scrollbars=1,resizable=yes');
return false;
return false is of no use here
it has to be in the link :
onclick="popup(this,800,600); return false;"
}
Following is not a goog idea if the popup have to be set to new size
(if width and/or height are different from precedent call)
so delete it
else
{
new_window.focus();
return false;
}
}

Code end
========

--
Stephane Moriaux et son [moins] vieux Mac
Aug 12 '05 #18
Markus wrote :
Gérard Talbot wrote:

1- new_window should be properly declared as a global variable
done

2- you can replace '_blank' with a parameter transferring, copying the
target attribute value. This makes your function better parameterized,
reusable.


done

3- there must not be any blank space in the windowFeatures string list.
Here, you have one between each of the commas and the following name of
the windowFeature. This will break in Firefox and other Mozilla-based
browsers.
ASM answered you correctly on this. You must remove blank spaces in the
windowFeatures string list, otherwise the parser will stop and truncate
the string.

eg
WindowObjectReference = window.open(strUrl, strWindowName,
"with=350,height=200,resizable,scrollbars");
is correct, is ok: the window will be 350px wide, 200px in height, will
be resizable and will have scrollbar(s) if needed, if content overflow
requested dimensions.

OTOH,
WindowObjectReference = window.open(strUrl, strWindowName, "with=350,
height=200, resizable, scrollbars");
is NOT correct, is NOT ok: the window will be 350px wide, but will have
an undefined height, will NOT be resizable and will NOT have
scrollbar(s) if needed, if content overflow requested dimensions: this
will happen in Netscape and in Mozilla-based browsers.

4- because of your blank spaces, scrollbars and resizable requests of
the window.open() call will be ignored


done

5- You request an height of 800px: that will fail in a very wide
majority of cases because a majority of 1024x768 users have about 660px
or less of available space for a window. So not only the window's top
will be reset by Mozilla/Firefox compensating positioning code, but your
window will not be 800 either.


This size will be ok. Our visitors have this huge resolution. We see
that on our stats.

6- do not use screen.width in any of your calculation; use
screen.availWidth and screen.availHeight since you have no idea of what
the user has in terms of semi-permanent os-dependent applications
(taskbar, MS-Magnification, Office quick launch bar, etc)


done

7- you make your call calculate top and left position but for
efficiency, best is to use a percentage of screen.availWidth and
screenAvailHeight


Can you give me an example ? The new code is at the end of this posting

8- Hint: only declare the windowFeatures which are requested, not the
ones you want to turn off, to disable


done

If you want a complete, recommendable and working example, use this document
http://developer.mozilla.org/en/docs/DOM:window.open


Thanks very much! :)

==========
Code start

var new_window = null;
var url = null;
function popup(element, width, height)
{


If you decide to send the element as a parameter, why not send its href
value instead and reduce the amount of testing on that link
(getAttribute) in that popup function of yours.
if (new_window == null || new_window.closed )
{
if (element.getAttribute)
{
url = element.getAttribute('href');
}
else
{
url = element;
}
new_window = window.open(url, 'tpc', 'width=' + width + ', height=' +
height + ', left=' + Math.round((screen.availWidth - width)/2) + ',
top=' + Math.round((screen.availHeight - height)/4)
Personally, I'd say away from those calculations. Your calculation can
sometimes get fooled by special semi-permanent os-dependent applications.

+ ',scrollbars=1,resizable=yes');
I see no blank space here, between scrollbars and resizable but the way
you constructed the string, there are blank space.
Eg:
', height='
is not
',height='
return false;
}
else
{
new_window.focus();
return false;
Return false is best used outside a function like this. Why? Because
that way you make your popup function reusable in the same site or in
another website project. Here, as mentioned by ASM, it's duplicated.
}
}

Code end
========


Gérard
--
remove blah to email me
Aug 14 '05 #19
ASM wrote :
Markus wrote:

The new code is at the end of this posting

==========
Code start

var new_window = null;
var url = null;
function popup(element, width, height)
{
if (new_window == null || new_window.closed )

// you must firstable close the popup if it is open

if (new_window != null || !new_window.closed)
new_window.close();


This is not perfectly illogical. The window could be minimized or behind
the parent window (which is a situation which can happen often). In such
case, you'd need to focus back the requested popup window and do nothing
more, assuming that the same 3 parameters are the same. Here, the code
makes no distinction; it just closes an already existing window and then
recreates it entirely. The code you propose is not the best, the most
efficient.
else
{
if (element.getAttribute)

if (element.getAttribute && element.getAttribute('href'))
or (I prefer) :
if(element.href)
{
url = element.getAttribute('href');

url = element.href;
}
else
{
url = element;
}
new_window = window.open(url, 'tpc', 'width=' + width + ',
height=' +
height + ', left=' + Math.round((screen.availWidth - width)/2) + ',
top=' + Math.round((screen.availHeight - height)/4) +
',scrollbars=1,resizable=yes');

Please : without space

new_window = window.open(url,'tpc','width=' + width +
',height=' + height +
',left=' + Math.round((screen.availWidth - width)/2) +
',top=' + Math.round((screen.availHeight - height)/4) +
',scrollbars=1,resizable=yes');
return false;

return false is of no use here
it has to be in the link :
onclick="popup(this,800,600); return false;"
}

Following is not a goog idea if the popup have to be set to new size
(if width and/or height are different from precedent call)
so delete it


Yes, you're right and I understand what you mean... but what if it uses
the same values? The thing is that the code makes no distinction, is not
smart enough to deal with such cases. One way is to store the href
value, width and height values in 3 global variables and then to compare
in the function. It's a bit more complicated. If the webpage
requirements are there, then this would be justified code.

Gérard
--
remove blah to email me
Aug 14 '05 #20
ASM
Gérard Talbot wrote:
ASM wrote :
[snip]

(Following = something about popup focus)
Following is not a goog idea if the popup have to be set to new size
(if width and/or height are different from precedent call)
so delete it


Yes, you're right and I understand what you mean... but what if it uses
the same values?


I have to considere uses can be different from call to call
If not, width and height parameters have no sens
(no utility in function calls)
The thing is that the code makes no distinction, is not
smart enough to deal with such cases. One way is to store the href
value, width and height values in 3 global variables
A so usual and simple popup would really need more JS work with global
variables ?
and then to compare
in the function. It's a bit more complicated. If the webpage
requirements are there, then this would be justified code.


I think popup focus in end of code would have to exist if there is a
possbility it allready does exists.
In this case a window resizing would before hapen in the function.
But it seems that some browsers don't resize windows ?
(in same way as others)

i.e

function pop(page,width,height) {
var margh = screen.availHeight? screen.availHeight : screen.height;
margh = (margh-height)/2-30;
var margl = screen.availWidth? screen.availWidth : screen.width;
margl = (margl-width)/2-10;
if(!(!truc) || !truc.closed) '';
else truc = window.open('','','resizable=1,scrollbars=1');
with(truc) {
location.href = page;
resizeTo(width,height);
moveTo(margl,margh);
focus();
}
}

--
Stephane Moriaux et son [moins] vieux Mac
Aug 14 '05 #21
ASM wrote :
Gérard Talbot wrote:
ASM wrote :

[snip]

(Following = something about popup focus)
Following is not a goog idea if the popup have to be set to new size
(if width and/or height are different from precedent call)
so delete it

Yes, you're right and I understand what you mean... but what if it
uses the same values?

I have to considere uses can be different from call to call
If not, width and height parameters have no sens
(no utility in function calls)
The thing is that the code makes no distinction, is not smart enough
to deal with such cases. One way is to store the href value, width and
height values in 3 global variables

A so usual and simple popup would really need more JS work with global
variables ?
and then to compare in the function. It's a bit more complicated. If
the webpage requirements are there, then this would be justified code.

I think popup focus in end of code would have to exist if there is a
possbility it allready does exists.

Right. If it already exists and if it uses the same parameters
In this case a window resizing would before hapen in the function.
Not reliable. Most alternative browsers now allow users to disable move
and resize script functions.
But it seems that some browsers don't resize windows ?
(in same way as others)

then store the parametrs in global variables between calls and compare
with current parameters. You then avoid all calls to moveTo, resizeTo.

E.g. the function OpenRequestedPopup(strUrl) which reuses and recycles a
single secondary window at this page:

http://www.gtalbot.org/BrowserBugsSection/MSIE6Bugs/

It also gives an example of scalable positioning of the window within
the available space for applications.
i.e

function pop(page,width,height) {
var margh = screen.availHeight? screen.availHeight : screen.height;
margh = (margh-height)/2-30;
Why - 30? screen.availHeight already considers the height of the windows
task bar and the height of any semi-permanent os-dependent
applications (like MS-Office quick launch bar, MS-magnify, etc). The
window taskbar could be higher than 30 too. Some people (rare but it
happens) likes to have the window taskbar at the top. Personally, I like
having a 64px high window taskbar because I have many icons in the quick
launch bar.
var margl = screen.availWidth? screen.availWidth : screen.width;
margl = (margl-width)/2-10;
Same here. screen.availWidth considers the width of any semi-permanent
os-dependent applications on the desktop. So, screen.availWidth is the
reliable width that a browser window can safely use. In some countries
where text is read from right to left, the window taskbar is on the left
side.
if(!(!truc) || !truc.closed) '';
This instruction above seems suspicious...
else truc = window.open('','','resizable=1,scrollbars=1');
with(truc) {
location.href = page;
resizeTo(width,height);
resizeTo and moveTo can be neutralize in a large number of browsers
(Opera 7+, Mozilla-based).
moveTo(margl,margh);
focus();
}
}


Gérard
--
remove blah to email me
Aug 16 '05 #22
ASM
Gérard Talbot wrote:
ASM wrote :
i.e

function pop(page,width,height) {
var margh = screen.availHeight? screen.availHeight : screen.height;
margh = (margh-height)/2-30;

Why - 30? screen.availHeight already considers the height of the windows
task bar and the height of any semi-permanent os-dependent applications


Who did speak about window ? -> SCREEN.availHeight

so : -30 for the naked browser's window top marge
to leave space to browser's window titlebar and some security
(some browsers don't accept to hide the statusbar)
(like MS-Office quick launch bar, MS-magnify, etc). The window taskbar
could be higher than 30 too.
don't know what about you talk :
isn't it included in screen.availHeight ? (Windows taskbar, Mac menubar)

but, because I do no trust in window.availSizes, I keep fiew space for
the browser's window bars of lifts
Some people (rare but it happens) likes to
have the window taskbar at the top. Personally, I like having a 64px
high window taskbar because I have many icons in the quick launch bar.
var margl = screen.availWidth? screen.availWidth : screen.width;
margl = (margl-width)/2-10;
Same here. screen.availWidth considers the width of any semi-permanent
os-dependent applications on the desktop. So, screen.availWidth is the
reliable width that a browser window can safely use. In some countries
where text is read from right to left,


not only ... it's a free choice of user (I think ... no PC win by here)
the window taskbar is on the left
side.


so ... no problemo no ?
if(!(!truc) || !truc.closed) '';

This instruction above seems suspicious...


IE is so often crying about non important things
I'd mistake ! :-(

if(!(!truc) || truc.closed) '';
else truc.close();
truc=window.open( blah )
with(truc) {
location.href = page;
resizeTo(width,height);


resizeTo and moveTo can be neutralize in a large number of browsers
(Opera 7+, Mozilla-based).


I know. All as blank window or popup (even launched by link or button)

With all these user's preferences setting
what will yet can we do my dear sir?
:-)
--
Stephane Moriaux et son [moins] vieux Mac
Aug 17 '05 #23
I really wish you people would learn English. I specifically choose to only list sites that are in English in Google, then I have to wait for this page to load up, only to find this dribble.

You sound like IDIOTS! My advise is this: UNTIL YOU LEARN ENGLISH PROPERLY, STICK TO YOUR OWN LANGUAGE, YOU DON'T REALISE HOW STUPID YOU SOUND.

PS: You also need to learn Javascript you posers.

STUPID EUROTRASH - GO BACK TO HELL!!!

STOP TRYING TO PRETEND YOU HAVE ADEQUATE ENGLISH!
WHY SHOULD WE HAVE TO SUFFER BECAUSE OF YOUR DISABILITY?

IF I HAVE TO WAIT TO WASTE MY PRECIOUS TIME LOADING ANOTHER PAGE THAT IS HARD TO READ DUE TO INACCURATE ENGLISH, FOREIGNERS ARE GOING TO BE KILLED - I PROMISE
Sep 25 '05 #24

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

Similar topics

2
by: Maik | last post by:
I Need a popup-killer script
8
by: Bijoy Naick | last post by:
It seems like the BBC sports site is able to get past popup blockers.. For eg.. http://news.bbc.co.uk/sport1/hi/cricket/default.stm. Click on the Video icon under "Watch and Listen" - right hand...
1
by: Bill H | last post by:
I run a dbms application that interfaces with the web. This module creates a frames page with two frames ('main' and 'mwinfoframe'). All communication with the dbms is routed through the...
11
by: Aaron | last post by:
I am trying to reuse a popup in my application. The reused popup also opens another popup. From this final popup I then try and reference a function located in the window that origionally opened...
4
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with...
3
by: Alex | last post by:
Hi, I'm having some trouble implementing a popup in firefox. I attached some simplified code at the bottom. This is part of a firefox extension. What happens is that a popup window is created,...
11
by: Alex.Svetos | last post by:
Hello, I'm trying to get a popup to keep focus when it is re-clicked. The script below is supposed to produce this exact behaviour, however it doesn't work, at least on firefox 1.0.7 and moz...
5
by: James Black | last post by:
In Firefox I can resize the window that is created, but in IE I can't. Here is the code I am using: var...
1
by: gvrajkumar | last post by:
Hi Popup window is opened and after some time session has expired. After session expire, if the user tries to make any actions on the popup page the user is redirected to login.jsp page. What...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.