milov.nl

Interaction design • webdevelopment • web art • photography

milov.nl : forum : coding : 'Javascript popup windows'

Javascript popup windows Andrew, 020116 17:36
I'm currently using a script to pop up windows that breaks right click and non js browsers:

[code[<a href="javascript:popup('foo.html', 'what_discharge', 500, 450, 'yes')">[/code[

I'd really like to be able to use something like was posted earlier:

<a href="foo.html" onclick="popup('this.href', 'pollution', 500, 450, 'yes')">
 

But this.href isn't working (my script expects a url). I've tried making a few substitutions in my script, and I just can't get it to work the same way. There are several variables I like to store in the script, which is why I'm not just calling window.open from the onclick.

Any suggestions? Here's the script I'm using:

<script type="text/javascript">
function popup(url, name, height, width, scrollbars)
{
var popwin;
var opts = "toolbar=no,status=no,location=no,menubar=no,resizable=no";
opts += ",height=" + height + ",width=" + width + ",scrollbars=" + scrollbars;

popwin = window.open("", name, opts);

popwin.focus();

popwin.location = url;

}
</script>
 

thanks!

131.247.163.118
Re: Javascript popup windows milov, 020116 17:53
I noticed one error in your code: you have 'quotes' around this.href, where there shouldn't be any. Also, I'd recommend adding a return false statement to the bottom of your function, to prevent the href from opening twice. The corrected script should look something like this:
<script type="text/javascript">
<!--
function popup(url, name, height, width, scrollbars)
{
var popwin;
var opts =
"toolbar=no,status=no,location=no,menubar=no,resizable=no";
opts += ",height=" + height + ",width=" + width +
",scrollbars=" + scrollbars;

popwin = window.open("", name, opts);
popwin.focus();
popwin.location = url;

return false;
}
-->
</script>

<a href="foo.html"
onclick="return popup(this.href, 'pollution', 500, 450, 'yes');">test</a>
 
webkracht.xs4all.nl
Re: Javascript popup windows ceer, 020125 14:17
I want to adapt that to imagemap, but I can't fix this code:

<img src="image.gif" border="0" usemap="#mapname">
<map
name="mapname"
onclick="return popup(areaid.href, 'pollution', 500, 450, 'yes');">
<area
id="areaid"
href="foo.html"
shape="rect"
coords="10,10,30,30"
>
</map>
 

what's wrong ?
aboukir-101-1-14-choukran.adsl.nerim.net
Re: Javascript popup windows milov, 020125 15:47
You probably have to add the onclick-event to the <area>-tag, rather than the <map>-tag.
...
<area
id="areaid"
href="foo.html"
onclick="return popup(this.href, 'pollution', 500, 450, 'yes');">
shape="rect"
coords="10,10,30,30"
>
</map>
 
kf-nawij-tg01-0274.dial.kabelfoon.nl
Re: Javascript popup windows jhgj, 020228 00:46
jhhgj
netcache1.csus.edu
Re: Javascript popup windows sdf, 020409 12:19
sdfsdf
095.b.006.syd.iprimus.net.au
Re: Javascript popup windows jon, 020411 20:35
hey there,
i was just looking at your code onm internet.com- very cool

i have something very similar placed here:
http://www.mercurylines.com

i have a dilemna. since each window on my site pops up a different
size on this page, i need it to open a unique window each time. if you
could look at my code on this page http://www.mercurylines.com and
help me out on how i could do this, i would be extremely grateful

thanks for your time
joanthan moore
65.166.169.164
Re: Javascript popup windows inbox.lv,kabis,b_smoke, 020425 19:40
hello is there some body who knows how to remove part of the window with "blabla - Microsoft Internet Explorer" and get only border
193.108.144.221
Re: Javascript popup windows milov, 020425 19:50
b_smoke: try the 'chromeless' script at http://www.microbians.com/ .
kf-nawij-tg01-0275.dial.kabelfoon.nl
Re: Javascript popup windows 4, 020603 20:50
eyey
209.158.197.2
Re: Javascript popup windows btinternet.com,psychotiq,Gary Paluk, 020630 12:01
<script type="text/javascript">
<!--
function popup(url, name, height, width, scrollbars)
{
var popwin;
var opts =
"toolbar=no,status=no,location=no,menubar=no,resizable=no";
opts += ",height=" + height + ",width=" + width +
",scrollbars=" + scrollbars;

popwin = window.open("", name, opts);
popwin.focus();
popwin.location = url;

return false;
}
-->
</script>

<a href="foo.html"
onclick="return popup(this.href, 'pollution', 500, 450, 'yes');">test</a>

Is there a way, using this code, to make the popups postition be 100,100?
host213-122-203-109.in-addr.btopenworld.com
Re: Javascript popup windows 23JUL, 020702 02:08
>Is there a way, using this code, to make the popups postition be 100,100?

Do some view-source:http://entries.the5k.org/1067/index.html
f127068.upc-f.chello.nl
Re: Javascript popup windows bx, 020909 12:20
bxb
203.199.202.97
I want my index page to load in fullscreen frameless when… GreasyMidget, 020926 00:12
How in the heck can i do this without loading a splash screen first then the main page i want. another words when people type in www.rdempster.com they get a fullscreen frameless explorer.
perm76-33.ij.net
Re: Javascript popup windows milov, 020926 11:48
Well, if you *want* to annoy people with an unannounced fullscreen window, something like this should suffice:
<body onload="window.open('fullscreen.html','_blank','fullscreen=yes');">
 But seriously, fullscreen sucks. Don't use it.
webkracht.xs4all.nl
Re: Javerscript popup windows swerrwerwe, 021023 21:27
wrwerwerw
200.12.84.97
Re: Javascript popup windows -> problem in Opera? Anne, 021112 18:59
This script does not work in Opera 5.0 and 6.0 / MacOS9.

Unless, I change:


popwin = window.open("", name, opts);
popwin.focus();
popwin.location = url;
 

into


popwin = window.open(url, name, opts);
popwin.focus();
 

Can somebody explain to me why this is working and whether this change has any drawbacks? The changed code still works in IE5.1/Mac and Mozilla1.1a/Mac.

Thanks!
217.20.199.144
Re: Javascript popup windows 23JUL, 021112 19:18
I am not sure, but it looks like Opera stops finishing the script at the moment it looses focus (that is: popwin gets the focus, opener gets blurred).

You may try to swap the last two lines of the first script or run a script from the popped-up window via the window.opener property.

http://www.devguru.com/Technologies/ecmascript/quickref/window.html


f109101.upc-f.chello.nl
Re: Javascript popup windows Anne, 021112 19:45
Thanks for your quick response.

I have tried swapping the last two lines as you suggested, but the window Opera opens is still empty.

Regarding your alternative solution: I do not know how to pass the href through the window.opener property. I will try to find out though. The link you kindly supplied will certainly help me with that.

Still, I am curious to know whether the changes I made to the original script will have any drawbacks. Is it still valid Javascript?
217.20.199.144
Re: Javascript popup windows 23JUL, 021112 22:07
I see no reason why it shouldn't be valid code.
It doesn't have any drawbacks either; in case of Mac/Opera: the contrary ;)

f109101.upc-f.chello.nl
Re: Javascript popup windows Anne, 021112 22:44
Thank you for the reinforcement.

I am no Javascript expert - as you have probably understood by now - and thought that by changing these lines I would remove some contingency code, like the
popwin.focus ();
  statement and the
return false;
  statement mentioned in the first reply in this thread.
dclient217-162-145-201.hispeed.ch
Re: Javascript popup windows Anne, 021112 23:38
Thank you for the reinforcement.

I am no Javascript expert - as you have probably understood by now - and thought that by changing these lines I would remove some contingency code, like the
popwin.focus ();
  statement and the
return false;
  statement mentioned in the first reply in this thread.
dclient217-162-145-201.hispeed.ch
Re: Javascript popup windows Anne, 021112 23:39
Thank you for the reinforcement.

I am no Javascript expert - as you have probably understood by now - and thought that by changing these lines I would remove some contingency code, like the
popwin.focus ();
  statement and the
return false;
  statement mentioned in the first reply in this thread.
dclient217-162-145-201.hispeed.ch
Re: Javascript popup windows chromeless, 030228 21:20
www.chromeless.org
44.Red-80-58-4.pooles.rima-tde.net
Re: Javascript popup windows nomail.com,sory,Vytas, 030508 19:28
if you want your script:
--------------------------
<a href="foo.html" onclick="popup('this.href', 'pollution', 500, 450, 'yes')">
--------------------------
do this:
--------------------------
<a href="javascript:popup('this.href', 'pollution', 500, 450, 'yes'); window.location.href='foo.html';">

193.219.90.85
Re: Javascript popup windows milov, 030508 20:16
Lose the quotes around this.href:
<a href="foo.html" onclick="popup(this.href, 'pollution', 500, 450, 'yes')">
 
kf-nawij-tg01-1194.dial.kabelfoon.nl
Re: Javascript popup windows biwols, 030519 23:53
use the image map to choose the links then in the
<a href="...">
  use this instead:


<a href="#" onClick="popup1()">.....

 

here is the popup script:


<script language="javascript">
<!--
function popup1()
{
window.open('address of page','new','height,width,status,toolbars,menus,scrollbars');
}
//-->
</script>
 
209.32.67.106
Re: Javascript popup windows hotmail.com,vracasanastasia,moi, 030529 13:43
popup without status bar.
And without de X to close window
195.167.98.121
Re: Javascript popup windows mio, 030529 13:44
popup width:
NO status bar
NO x to close wondow
195.167.98.121
Re: Javascript popup windows Dionne, 030905 19:04
that code is seriously not working for me on IE 6.0
ip-64-237-65-153.eatel.net
Re: Javascript popup windows wp.pl,kosteku,kostek, 030918 13:05
[empty]
tl162.internetdsl.tpnet.pl
Re: Javascript popup windows Las Jose, 031021 22:30
Hey Guys,

I'm using the code you've posted to display images. I was wondering if there is a way in IE 6 to remove the white border around the image when it is displayed in a new window. I know this can be done in the html by declaring: <body topmargin="0" leftmargin="0"> Is there a way to pass these margins through the javascript to the next page?

63.88.130.213
Re: Javascript popup windows hotmail.com,makino_dms,eugenia, 031110 04:40
hi i have some problems with my pop up window.. but i cannot find wat's wrong with it.. here is the code...

<A onclick="open('wl.htm','miniwin','toolbar=0,location=0,directories=0,status=0,
menubar=0,scrollbars=1,resizable=1,width=435,height=300')"
href="javascript:void(0)">

by eugenia
203.127.190.20
Re: Javascript popup windows BillTheCat, 040203 20:02
Got no semi-colons to seperate the lines.
A onclick="open('whatever.html','miniwin','toolbar=0,location=0,directories=0,status=0, menubar=0,scrollbars=1,resizable=1,width=435,height=300');" href="javascript:void(0);">

Gotta have the semicolons otherwise the script works GREAT!!
Thanks for the idea!
mawi-dedicated-216-170-169-12.dedicated.tds.net
Re: Javascript popup windows sas.com,sdfds,sdfgsd, 040205 22:48
thx
217.29.240.36
Re: Javascript popup windows hotmail.com,jamesetakacs,jimmy t, 040316 05:52
i get a small border around the image placed inside the popup that comes up. the image is in place, but there is like 5 pixel border in between the image and the window. someone told me it was the default page border, how do i fix it?
d47-69-145-193.try.wideopenwest.com
Re: Javascript popup windows ss, 040319 14:46
sss
212.48.13.3
Re: Javascript popup windows yahoo.com,proserv394,Tony, 040328 04:15
Hi,
I was wondering has anyone seen the Ellen degeneres site.
if you click on the intro button at the bottom left of the site right below her picture it plays a video. of doing some stuff to her site. Does anyone know how they did that>


adsl-154-173-185.bna.bellsouth.net
Re: Javascript popup windows Calm_Pear, 040328 10:51
that's done with flash, nothing to do with javascript.
node-c-0404.a2000.nl
How do i prevent popups using javascript Spaz-Monkey.co.uk, 040506 22:30
I wanna stop popups on my site http//www.elusiononline.tk with a javascript

Can anyone help me
host217-44-113-11.range217-44.btcentralplus.com
Re: Javascript popup windows Calm_Pear, 040526 20:46
Hi Spaz-Monkey,

To keep the answer short, no. Only the people that host the framepage at elusiononline.tk can do that. Sorry, there are no workarounds. Just skip the tk domain name, there's nothing wrong with http://www.spaz-monkey.co.uk/elusion/

node-c-66d2.a2000.nl
Javascript popup windows' status bar gmail.com,tutelage,ted, 050104 06:00
I use 'status=no' in the attributes for opening a pop-up window. For some reason the same code hides the status bar in Netscape 7, but not Mozilla v1.0 nor IE6. Does someone know the suggestions to hide the status bar in Mozilla and IE6

-thanks in advance

======================================================
for reference here's the code

<script type="text/javascript">
<!--
var x = 'height=250,width=340,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no,directories=no';
function blah() { window.open ('http://www.webs.com','new', x) }
//-->
</script>
69-0-10-145.mrdnct.adsl.snet.net
Re: Javascript popup windows kamran, 050424 18:39
can you make the root of the site javascript popup
host-84-9-25-223.bulldogdsl.com
Pages: 1