Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > popup problem with FF

Reply
Thread Tools

popup problem with FF

 
 
Paul J. Le Genial
Guest
Posts: n/a
 
      03-16-2005
Hello,

I have a problem with this script in Firefox :

var ipp =
window.open("","MadoPop","width=100,height=100,dep endant=yes,resizable=no,ho
tkeys=no",true);
ipp.document.write('<html><body>test</body></html>');
ipp.document.close();
ipp.focus;

The popup windows that opens is resizable and has a visible statusbar. What
can I do to disable these two features ?


I know that people don't like popup windows ...unless they know what will
happens and choose to open it:
I want the ability to show enlarged pictures out of my text with a popup.
Events onclick and onblur in the popup will close it.
An advertisement will be displayed below each enlargeable picture to explain
that a popup will be created.

TIA


 
Reply With Quote
 
 
 
 
kaeli
Guest
Posts: n/a
 
      03-16-2005
In article <4238733a$0$44091$(E-Mail Removed) >,
http://www.velocityreviews.com/forums/(E-Mail Removed) enlightened us with...

>
> I have a problem with this script in Firefox :
>


I'm surprised that's the only one.
You can't go misspelling param names and adding arguments. Trust IE to try to
figure it out for you instead of telling you that you did something wrong.

You do know that Firefox has a javascript console to show you errors, right?
Type
javascript:
in the URL address bar or do Tools->Javascript Console.

> var ipp =
> window.open("","MadoPop","width=100,height=100,dep endant=yes,resizable=no,ho
> tkeys=no",true);


window.open("","MadoPop","width=100,height=
100,dependent=yes,resizable=no,hotkeys=no,status=n o");

And what's with the extra "true" param? The method window.open() only takes
3. Not 4.

Google is your friend.
http://www.devguru.com/Technologies/.../win_open.html

--
--
~kaeli~
Experience is something you don't get until just after you
need it.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
 
 
 
Paul J. Le Genial
Guest
Posts: n/a
 
      03-16-2005

"kaeli" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In article <4238733a$0$44091$(E-Mail Removed) >,
> (E-Mail Removed) enlightened us with...
>
> >
> > I have a problem with this script in Firefox :
> >

>
> I'm surprised that's the only one.
> You can't go misspelling param names and adding arguments. Trust IE to try

to
> figure it out for you instead of telling you that you did something wrong.
>
> You do know that Firefox has a javascript console to show you errors,

right?
> Type
> javascript:
> in the URL address bar or do Tools->Javascript Console.
>
> > var ipp =
> >

window.open("","MadoPop","width=100,height=100,dep endant=yes,resizable=no,ho
> > tkeys=no",true);

>
> dependent=yes,resizable=no,hotkeys=no,status=no");

OK, I wrote "dependant", but that was not the reason of the problem. I added
these params
to try to solve the problem, without success.

Here is the complete script:

function showPict(img,x,y) {
var text='<html><body onblur="this.close()" ';
text += 'onclick="this.close()" background="'; // onclick is not working in
FF
text += param;
text += '" onload="this.resizeTo('+ x + ',' + y + ')">test</body></html>'
var ipp =
window.open("","MadoPop","width=100,height=100,dep endent=yes,resizable=no,ho
tkeys=no",true);
ipp.document.write(text);
ipp.document.close();
ipp.focus;
}


And in the body of the page, I have:
<a href="javascript:void()" onclick="showPict('image.jpg',680,540)"><img
src="small-image.jpg" width="200" height="152" border="0"></a>

The popup is resizable and has a status bar in FF (why ?), not in IE.


> And what's with the extra "true" param? The method window.open() only

takes
> 3. Not 4.
>

from this site :
http://javascriptkit.com/jsref/window.shtml

"open(URL, [name], [features], [replace])"

"Opens a new browser window. "Name" argument specifies a name that you can
use in the target attribute of your <a> tag. "Features" allows you to
show/hide various aspects of the window interface. "Replace" is a Boolean
argument that denotes whether the URL loaded into the new window should add
to the window's history list. A value of true causes URL to not be added."

This argument is not the reason of my errors.


 
Reply With Quote
 
Paul J. Le Genial
Guest
Posts: n/a
 
      03-16-2005
> function showPict(img,x,y) {
> var text='<html><body onblur="this.close()" ';
> text += 'onclick="this.close()" background="'; // onclick is not working

in
> FF

Sorry, onclick works in FF but not in IE

> text += param;
> text += '" onload="this.resizeTo('+ x + ',' + y + ')">test</body></html>'
> var ipp =
>

window.open("","MadoPop","width=100,height=100,dep endent=yes,resizable=no,ho
> tkeys=no",true);
> ipp.document.write(text);
> ipp.document.close();
> ipp.focus;
> }
>
>
> And in the body of the page, I have:
> <a href="javascript:void()" onclick="showPict('image.jpg',680,540)"><img
> src="small-image.jpg" width="200" height="152" border="0"></a>
>
> The popup is resizable and has a status bar in FF (why ?), not in IE.



 
Reply With Quote
 
RobB
Guest
Posts: n/a
 
      03-16-2005
Paul J. Le Genial wrote:
> > function showPict(img,x,y) {
> > var text='<html><body onblur="this.close()" ';
> > text += 'onclick="this.close()" background="'; // onclick is not

working
> in
> > FF

> Sorry, onclick works in FF but not in IE
>
> > text += param;
> > text += '" onload="this.resizeTo('+ x + ',' + y +

')">test</body></html>'
> > var ipp =
> >

>

window.open("","MadoPop","width=100,height=100,dep endent=yes,resizable=no,ho
> > tkeys=no",true);
> > ipp.document.write(text);
> > ipp.document.close();
> > ipp.focus;
> > }
> >
> >
> > And in the body of the page, I have:
> > <a href="javascript:void()"

onclick="showPict('image.jpg',680,540)"><img
> > src="small-image.jpg" width="200" height="152" border="0"></a>
> >
> > The popup is resizable and has a status bar in FF (why ?), not in

IE.

Firefox allows users to disable toggling of the status bar or
resize-ability by scripts. See the Options/Preferences Window for
details.

Might go:

text += 'onclick="top.close()"....

 
Reply With Quote
 
kaeli
Guest
Posts: n/a
 
      03-16-2005
In article <423892d0$0$44077$(E-Mail Removed) >,
(E-Mail Removed) enlightened us with...
>>

> function showPict(img,x,y) {
> var text='<html><body onblur="this.close()" ';
> text += 'onclick="this.close()" background="'; // onclick is not working in
> IE


The "this" keyword may not be pointing to the object you assume it is. In
fact, I bet it refers to the document object in MSIE (and to window in FF).
Which won't close the window in IE.
Try self.close().

> text += param;
> text += '" onload="this.resizeTo('+ x + ',' + y + ')">test</body></html>'


Again, for cross-browser scripting, best to specifically call window.resizeTo
(or self.resizeTo). Don't use "this". It refers to document in some browsers
and window in others.

> var ipp =
> window.open("","MadoPop","width=100,height=100,dep endent=yes,resizable=no,ho
> tkeys=no",true);


You need to set status=no for some browsers. Try that. I always specifically
set them to no when I want to make sure they aren't there.

> ipp.document.write(text);


I believe you have to open it first. If you don't have to, it's still better
form.
ipp.document.open();
ipp.document.write(text);
ipp.document.close();

>
>
> And in the body of the page, I have:
> <a href="javascript:void()"


Ooh, icky. Old skool. In a bad way.

<a href="someNonJsWarningPage.html"
onClick="showPict('image.jpg',680,540);return false;">


>
> The popup is resizable and has a status bar in FF (why ?),


Keep in mind that FF allows me to tell my browser to not allow scripts to
disable those things. Check your FF preferences before you think your script
is actually broken. In MY FF, you can't open a new window at all.
It will open in a new tab no matter what your script says. I set it up that
way because I hate when people spawn popups. That means when you resize, it
resizes EVERYTHING, so I have that turned off, too.
FF is all about customization.

I don't remember what the defaults are, so check what your scripts are set to
be allowed to do. Tools->options->web features
Click Advanced button. Make sure "move or resize windows" is checked and
"hide the status bar" is checked. Mine are both unchecked.

>
> > And what's with the extra "true" param? The method window.open() only

> takes
> > 3. Not 4.
> >

> from this site :
> http://javascriptkit.com/jsref/window.shtml
>
> "open(URL, [name], [features], [replace])"


That is not official documentation.
This is. Well, for Gecko anyway.
http://www.mozilla.org/docs/dom/domr...dow_ref76.html

The 4 args is, apparently, MSIE specific, since MSIE docs have it and Gecko
does not. This is not unusual. Different browsers support different things.
http://msdn.microsoft.com/workshop/a...ods/open_0.asp

Be careful what references you read and always check the browser
documentation to see what is supported.

> This argument is not the reason of my errors.


Probably not (probably ignores that 4th one), but it might really fudge up
Safari, for all I know.

--
--
~kaeli~
Contrary to popular opinion, the plural of 'anecdote' is
not 'fact'.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

 
Reply With Quote
 
Paul J. Le Genial
Guest
Posts: n/a
 
      03-16-2005
>
> Firefox allows users to disable toggling of the status bar or
> resize-ability by scripts. See the Options/Preferences Window for
> details.


OK, in javascript preferences I checked "allow disabling statusbar" and the
two problems
were solved: no statusbar and popup not resizable

>
> Might go:
>
> text += 'onclick="top.close()"....


OK, it works. self.close() is working too (thanks to kaeli)


 
Reply With Quote
 
Paul J. Le Genial
Guest
Posts: n/a
 
      03-16-2005

"kaeli" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In article <423892d0$0$44077$(E-Mail Removed) >,
> (E-Mail Removed) enlightened us with...
> >>

> > function showPict(img,x,y) {
> > var text='<html><body onblur="this.close()" ';
> > text += 'onclick="this.close()" background="'; // onclick is not

working in
> > IE

>
> The "this" keyword may not be pointing to the object you assume it is. In
> fact, I bet it refers to the document object in MSIE (and to window in

FF).
> Which won't close the window in IE.
> Try self.close().


OK, it is working now. I didn't thought of it because onblur was working
correctly. Of course, it was not applying to the same object.

> >
> >
> > And in the body of the page, I have:
> > <a href="javascript:void()"

>
> Ooh, icky. Old skool. In a bad way.
>
> <a href="someNonJsWarningPage.html"
> onClick="showPict('image.jpg',680,540);return false;">


Is the "return false;" mandatory ? What is its role ? Can it be moved as the
last statement of the showPict function definition ?



> > The popup is resizable and has a status bar in FF (why ?),

>
> Keep in mind that FF allows me to tell my browser to not allow scripts to
> disable those things. Check your FF preferences before you think your

script
> is actually broken. In MY FF, you can't open a new window at all.
> It will open in a new tab no matter what your script says. I set it up

that
> way because I hate when people spawn popups. That means when you resize,

it
> resizes EVERYTHING, so I have that turned off, too.


So, would it be better to do it like this :
var ipp=eval(window.open("","MadoPop","width='+x+',hei ght='+y+'")');
without the need to use resizeTo ?

> I don't remember what the defaults are, so check what your scripts are set

to
> be allowed to do. Tools->options->web features
> Click Advanced button. Make sure "move or resize windows" is checked and
> "hide the status bar" is checked. Mine are both unchecked.


OK, that's fine now.

Thank you for your clear explanations.


 
Reply With Quote
 
Paul J. Le Genial
Guest
Posts: n/a
 
      03-16-2005

"kaeli" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> In article <423892d0$0$44077$(E-Mail Removed) >,
> (E-Mail Removed) enlightened us with...
> >>

> > function showPict(img,x,y) {
> > var text='<html><body onblur="this.close()" ';
> > text += 'onclick="this.close()" background="';
> > text += img;
> > text += '" onload="this.resizeTo('+ x + ',' + y +

')">test</body></html>'
>

I tried to replace the background="" parameter of the body tag by :
<head><style>BODY { background: black url('+img+')
no-repeat;}</style></head>
(I also tried : { background-image: url('+im+'); } )

Works in IE but in FF the style don't seems to be applied (no image
displayed)


 
Reply With Quote
 
Randy Webb
Guest
Posts: n/a
 
      03-17-2005
Paul J. Le Genial wrote:

> "kaeli" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>In article <423892d0$0$44077$(E-Mail Removed) >,
>>(E-Mail Removed) enlightened us with...


<--snip-->

>>>And in the body of the page, I have:
>>><a href="javascript:void()"

>>
>>Ooh, icky. Old skool. In a bad way.
>>
>><a href="someNonJsWarningPage.html"
>>onClick="showPict('image.jpg',680,540);return false;">

>
>
> Is the "return false;" mandatory ?


No.

> What is its role ?


It stops the navigation of the href attribute.

> Can it be moved as the last statement of the showPict function definition ?


Only if you change the onclick to return showPict(....) and then return
false in the function.

>>>The popup is resizable and has a status bar in FF (why ?),

>>
>>Keep in mind that FF allows me to tell my browser to not allow scripts to
>>disable those things. Check your FF preferences before you think your

>
> script
>
>>is actually broken. In MY FF, you can't open a new window at all.
>>It will open in a new tab no matter what your script says. I set it up

>
> that
>
>>way because I hate when people spawn popups. That means when you resize,

>
> it
>
>>resizes EVERYTHING, so I have that turned off, too.

>
>
> So, would it be better to do it like this :
> var ipp=eval(window.open("","MadoPop","width='+x+',hei ght='+y+'")');
> without the need to use resizeTo ?


No, it is *never* better to use eval.

http://jibbering.com/faq/#FAQ4_40

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
 
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
Watir Javascript popup handler: How to handle the popup dialog? Rajesh Ruby 0 07-31-2007 04:36 AM
ASP.NET JavaScript Popup, No Popup Using Back Button dapkniht ASP .Net 1 03-08-2006 08:49 AM
Popup Window Popup Timing =?Utf-8?B?Sm9obiBXYWxrZXI=?= ASP .Net 3 11-04-2005 07:33 PM
Main > Popup > Popup > Close popup AND new URL in main? Jens Peter Hansen Javascript 7 06-19-2004 08:56 PM
trigger event on opener from popup when closing it or run opener script from popup Urs Gubler Javascript 0 07-02-2003 02:08 PM



Advertisments