Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > popup open problem only with firefox

Reply
Thread Tools

popup open problem only with firefox

 
 
Markus
Guest
Posts: n/a
 
      08-11-2005
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.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      08-11-2005
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
 
Reply With Quote
 
 
 
 
Markus
Guest
Posts: n/a
 
      08-12-2005
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.

 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      08-12-2005
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
 
Reply With Quote
 
Markus
Guest
Posts: n/a
 
      08-12-2005
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)

 
Reply With Quote
 
Markus
Guest
Posts: n/a
 
      08-12-2005
There is one probleme now: It don't work with IE . Now, i have to
find a solution.

 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      08-12-2005
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
 
Reply With Quote
 
Gérard Talbot
Guest
Posts: n/a
 
      08-12-2005
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

<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');



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
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      08-12-2005
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
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      08-12-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Page -> Popup -> New Page (close popup, leave old page open) julie.siebel@gmail.com Javascript 2 01-18-2006 12:57 AM
firefox 1.0 - how to override popup blocker selectively, how to enable work for only certain popups within same domain dejausenet@yahoo.com Javascript 1 01-25-2005 02:28 AM
How to open a popup when popup blocker is turned on Ashish Javascript 2 10-31-2004 07:00 PM
Main > Popup > Popup > Close popup AND new URL in main? Jens Peter Hansen Javascript 7 06-19-2004 08:56 PM
how do you only allow a popup to popup once David Graham Javascript 4 11-18-2003 04:16 PM



Advertisments