Một số cách để open 1 windows mới.
Cách 1:
<
script
>var new_window;
function popup(url)
{ new_window=window.open(url,'name','height=800,width=600');
if (window.focus) {new_window.focus()}
}</
script
>
* nội dung của cửa sổ là nội dung của url
Cách 2:
<
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
=
"javascriptopup();"
>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
if (window.focus) {new_window.focus()} // focus
<
a
href
=
"javascript:if(new_window) new_window.close()"
>Close</
a
>
Trên đây là 1 số cách tạo popup mà công ty
thiet ke web topweb đã sưu tầm đươc hi vọng nó sẽ mang lại cho bạn nhiều cảm nhận mới