View Full Version : Another question to M3ntal/Sel/anyone else about web coding - Popup Windows
thomasp
26 Jun 2006, 16:47
Note: the non-evil kind of popup windows ;)
Basically, I'm having a page with a list of clients (about 20) and "testimonials" on it - under each client is a short excerpt from their testimonial and a link which when clicked will open a new window (ideally, not a full-size window - lets say a window 100x500 pixels) with the whole testimonial in it. I can't use <a href="... " target="_blank">, because I don't really want a full-size window opening (but, if the popup script is going to be hideously long, then I will resort to this)
Also, in the new window (either popup or target="_blank"), how can I have a button that closes it and returns focus to the original window?
I've had a look on HTMLCodeTutorial.com, and their popup script seems horribly inefficient for 20+ links....
Thanks in advance for the help :D
SupSuper
26 Jun 2006, 17:56
Just use Javascript's window.open function:
<a href="javascript:newWindow = window.open('someDoc.html','subWind',
'width=100,height=500');newWindow.focus();">Some Text</a>
SomePerson
26 Jun 2006, 18:44
to close it, you should be able to put this in the new window's HTML file.
<a href="" onClick="self.close">Some Text</a>
Don't know how you'd do that with a button, though.
thomasp
26 Jun 2006, 18:47
Just use Javascript's window.open function:
<a href="javascript:newWindow = window.open('someDoc.html','subWind',
'width=100,height=500');newWindow.focus();">Some Text</a>
Cheers for that - seems a lot simpler than HTMLCodeTutorial.com's method...
to close it, you should be able to put this in the new window's HTML file.
<a href="" onClick="self.close">Some Text</a>
Don't know how you'd do that with a button, though.
That's actually better than a button, as I can now use my own image - thanks :)
Plutonic
26 Jun 2006, 19:17
wow, both parts answered before I even found the thread.. but uh... what they said :p
Slightly more concise, and compliant:
<a href="javascript:window.open('testimonial1.html', 'testimonial1', 'width=100,height=500'); testimonial1.focus()">View Full Testimonial</a>
And in testimonial1.html:
<a href="javascript:window.close()">close</a>
AndrewTaylor
28 Jun 2006, 12:43
Slightly more concise, and compliant:
<a href="javascript:window.open('testimonial1.html', 'testimonial1', 'width=100,height=500'); testimonial1.focus()">View Full Testimonial</a>
And in testimonial1.html:
<a href="javascript:window.close()">close</a>
Here's an even better way:
<a href="testimonial1.html" onClick="window.open('testimonial1.html', 'testimonial1', 'width=100,height=500'); testimonial1.focus(); return false" target="_blank">View Full Testimonial</a>
That should, if I've remembered it right, use target="_blank" as a fallback for paranoid folks without javascript enabled.
That's a more user-friendly solution, although target="_blank" is not XHTML compliant.
AndrewTaylor
28 Jun 2006, 19:54
Then how do you open a link in a new window in XHTML?
Plutonic
29 Jun 2006, 02:01
As far as I can tell, with javascript. If you want to use frames or other stuff like that you have to downgrade to xhtml 1.0 Transitional. Strict just doesnt support them. Other than that you can write your own DTD....... fun.
Then how do you open a link in a new window in XHTML?
You don't. XHTML is a markup to describe the meaning of data, it is not for describing how to display it, that's what CSS and scripting are for.
SupSuper
29 Jun 2006, 17:25
Well, that's just a pain in the tushy.
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.