cách 1: cách đơn giản nhất
Cách 2:
function popup(url)
{ new_window=window.open(url,'name','height=800,width=600');
if (window.focus) {new_window.focus()}
}</script>
<a href="javascript:popup('http://phpbasic.com');">Click here</a>
* nội dung của cửa sổ là nội dung của url
Cách 3:
<script type="text/javascript">
function popup()
{
var generator=window.open('','name','height=300,width=400,status=1');
generator.document.write('<html><head><title>Popup</title>');
generator.document.write('</head><body>');
generator.document.write('<h1>Welcome to phpbasic.com</h1>');
generator.document.write('<p>Noi dung cua o cua so nay do javascript qui dinh.</p>');
generator.document.write('<p><a href="javascript:alert(self.location.href)">Xem URL cua window</a>.</p>');
generator.document.write('<p><a href="javascript:self.close()">Close</a> the popup.</p>');
generator.document.write('</body></html>');
generator.document.close();
}
</script>
<a href="javascript:popup();">Click here</a>
* nội dung của cửa sổ do javascript qui định
Ghi chú: Đối số thứ 3 của hàm window.open có thể bao gồm các thuộc tính sau:
- height: chiều cao của popup, chỉ dùng đơn vị pixel (không dùng %)
- width: chiều rộng của popup, chỉ dùng đơn vị pixel (không dùng %)
- left: vị trí của popup so với lề trái của cửa sổ lớn
- top:vị trí của popup so với lề trái của cửa sổ lớn
- resizable: resize được kích thước của popup nếu là true
- scrollbars: xuất hiện scrollbars(thanh trượt) nếu là true
- toolbar: xuất hiên toolbar nếu là true
- menubar: xuất hiện menubar(File, Edit, ...) nếu là true
- location: hiển thị thanh điạ chỉ
- status: hiển thị status cho popup
focus và close cho popup
<a href="javascript:if(new_window) new_window.close()">Close</a>
Tác giả:TG
Webmaster
http://phpbasic.com

