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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

popup window 1

Status
Not open for further replies.

RobBroekhuis

Technical User
Oct 15, 2001
1,971
US
I found a way of using popup windows in the PHP forum FAQs, but thought this was probably a more appropriate forum to discuss. The code in my page is below:

Code:
<a href=&quot;registryprint.php?registrar=Cory&quot;,
   onclick=&quot;window.open this.href,'popupwindow','resizable'); return false;&quot;>
Printable page</a>

This worked just fine for a little while, and now it doesn't - IE just opens the page into the active window, not in a new one. Am I doing something wrong?


Rob
[flowerface]
 
Rob,

Modify your code to read:

[code<a href=&quot;registryprint.php?registrar=Cory&quot; onclick=&quot;window.open(this.href,'','resizable'); return false;&quot;>Printable page</a>[/code]

to solve the problem.

Because you are always calling your popup window 'popupwindow', it always references the same window. I removed this string.

Hope this helps!

Dan



Hope this helps!

Dan
 

Hmm.. that code should have read:

Code:
<a href=&quot;registryprint.php?registrar=Cory&quot; onclick=&quot;window.open(this.href,'','resizable'); return false;&quot;>Printable page</a>

Dan
 
Still no luck. I must confess to no even knowing what kind of language I'm invoking inside the double quotes (yes, I'm new HTML beyond the bare basics).


Rob
[flowerface]
 
Rob,

If you copy and paste the code below verbatim, does it work for you?

Code:
<HTML>
<HEAD>
</HEAD>
<BODY>
<A HREF=&quot;registryprint.php?registrar=Cory&quot; onClick=&quot;window.open(this.href,'','resizable'); return(false);&quot;>Printable page</A>
</BODY>
</HTML>

Dan
 
Yes, it does. For reference, I just copied the equivalent bit from my &quot;view source&quot; window:

Code:
<a
href=&quot;registryprint.php?registrar=Amy&quot;,onClick=&quot;window.open(this.href,'','resizable'); return(false);&quot;>Printable page</a>

I don't see a difference - do you?


Rob
[flowerface]
 

Clearly you didn't copy the code verbatim as I gave it to you then.. Commas don't just appear inbetween parameters by magic.

Remove the comma or copy the code I gave you without modifying it, and it should work.

Hope this helps,

Dan
 

Sorry - I should specified that I was talking about the command directly before &quot;onclick&quot;.

Dan
 
Ah - great, you found the difference my eyes wouldn't spot. I copied the snippet above from my own page (I had copied yours verbatim, and, as I mentioned, that worked just fine). I removed the comma, which I must have inserted inadvertently at some point, and all is well. Thanks much for your help. And the stars are working again, too!


Rob
[flowerface]
 
Keep in mind that having javascript turned off or having a popup blocker would stop this code from working... You may want to switch to using an &quot;
Code:
<a>
-tag&quot; with a target. Granted you can't turn on and off the menu/scroll/toolbar/ect. but you stand a better change of the age comming up. just a note.
 

jstreich,

Most popup blockers work on substring searchers from the window title.. So unless the popup had &quot;sex&quot; &quot;porn&quot;, &quot;free xxx&quot;, etc etc in the title, I doubt it would be blocked.

Only about 13% of people have JavaScript disabled, so I guess you could say that it was definately the minority.

And using TARGET= means that the code would never validate in HTML or XHTML strict mode.

Not rubbishing your solution... just giving you more reasoning behind why I chose mine.

Dan

 
Google's blocker blocks them all (as dose Mozilla's/netscape's built in blocker (i think))... Aside from people surfing with it turned off, also lok at text only browsers on *nix machines and text only browsing on handhelds like phones. With as correct as Mozilla/(netscape) is, I'm suprized that the
Code:
target=
is prefered by thier browser if it's not strict. Javascript is EVIL, it executes client side and dispite trying to work in a sandbox, it is not as restricted as it should be.

Pop-up in general are a bad idea, but when they must be done I still think target= is prefered. It may not validate in strict mode, but it will work in all browsers (text only will ignore the target tag (which is probably why it's not standard), and open it in the same window as oppose to never opening it with the JS approach)
 

I agree with you wholeheartedly about the link/popup debate.

Giving the user the choice of whether to open a link in a new window (or not) is a good thing... That and accessibility issues are probably behind the removal of the TARGET attribute from the strict DTDs.

I wouldn't go so far as to say that popups and javascript are bad, however. Like everything, they have their time and place.

Dan
 
I just think it's nicer to present a page meant only to be printed in a new browser window that can be left open and closed whenever, leaving the main application going in the original window. Why is that evil, or ill-advised? Not trying to butt heads, merely to understand...



Rob
[flowerface]
 

Rob,

It's not necessarily a really bad thing to use popups. I use them occasionally, more often when I know my target audience.

For example, if I'm coding a web application for a corporate intranet, I may use popups extensively. The users would undergo training on the app, and learn that the popup was part of the functionality.

Even on public facing websites, some popups are OK.

On an ecommerce site, you might feature a list of 50 products, each with some text detail, a thumbnail image, and a &quot;Click here for more info&quot; link next to each product.

I wouldn't consider putting a popup on that link to be bad, as the user action has caused it to open. Making it a standard A tag that opens the document in the same window would be more desirable, but a popup wouldn't be bad.

I think that it's mainly uninvited popups that annoy people (to put it mildly!).

Dan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top