Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need simple JS popup window

Status
Not open for further replies.

iluvperl

Programmer
Jan 22, 2006
107
I had a code once that popped up a new browser window at a custom size without all that browser button junk. It took out the toolbars, bottom bar, etc. It was just a really tiny window.

I need this to be a link though. Anyone have this code handy? Thanks!
 
iluvperl said:
I need this to be a link

The only reason you would [!]need[/!] something like this to be a link is if you wanted to cater for those with JS disabled... so having said that, this should work for you:

Code:
<a href="someUrl.html" onclick="var winHandle = window.open('', '', 'width=400,height=200'); return(false);">link</a>

If you have JS disabled, the link functions as normal. If JS is enabled, then the popup opens instead.

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Add target="_blank" to the link and it'll appear in a new window if you have javascript off.

Code:
<a href="someUrl.html" [b]target="_blank"[/b] onclick="var winHandle = window.open('', '', 'width=400,height=200'); return(false);">link</a>

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Hi.

Can any of you see why this is opening a window but NOT the link? the link WORKS, I tried it and so can you. But it opens a blank, untitled window instead of my URL.

Code:
<a href="[URL unfurl="true"]http://www.spyderscripts.com/cgi-bin/test/scramble.pl?checkword=settler"[/URL] onclick="var winHandle = window.open('', '', 'width=400,height=200'); return(false);">settler</a>, <a href="[URL unfurl="true"]http://www.spyderscripts.com/cgi-bin/test/scramble.pl?checkword=sterlet"[/URL] onclick="var winHandle = window.open('', '', 'width=400,height=200'); return(false);">sterlet</a><br/><br/><b>6 characters</b><br/><a href="[URL unfurl="true"]http://www.spyderscripts.com/cgi-bin/test/scramble.pl?checkword=letter"[/URL] onclick="var winHandle = window.open('', '', 'width=400,height=200'); return(false);">letter</a>
 
window.open simply opens a new window - you have to specify the window's URL as a parameter. Using [blue]this.href[/blue] is a convenient way of avoiding typing the same URL multiple times.

Code:
<a href="[URL unfurl="true"]http://www.spyderscripts.com/cgi-bin/test/scramble.pl?checkword=settler"[/URL] onclick="var winHandle = window.open([red]this.href[/red], '', 'width=400,height=200'); return(false);">settler</a>, 
<a href="[URL unfurl="true"]http://www.spyderscripts.com/cgi-bin/test/scramble.pl?checkword=sterlet"[/URL] onclick="var winHandle = window.open([red]this.href[/red], '', 'width=400,height=200'); return(false);">sterlet</a><br/><br/>
<b>6 characters</b><br/>
<a href="[URL unfurl="true"]http://www.spyderscripts.com/cgi-bin/test/scramble.pl?checkword=letter"[/URL] onclick="var winHandle = window.open([red]this.href[/red], '', 'width=400,height=200'); return(false);">letter</a>

---
Marcus
better questions get better answers - faq581-3339
accessible web design - zioncore.com
 
Oops - sorry - my original post had a glaring error which I failed to spot.

The "window.open" should change from this:

Code:
window.open([!]''[/!], ...

to this:

Code:
window.open([!]this.href[/!], ...

Sorry for the confusion!

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top