Window method
Window hamper sama dengan hyperlink
Hperlink bisa dibuka pada tab yang sama maupun lain dengan
ukuran sesuai dengan browser kita
Window seperti pop up window
nama_objek= window.open (URL,TITLE,OPTION);
mengapa objek?
Karena variable hanya menampung sebuah nilai
Sedangkan objek tidak menampung nilai tapi mengandung sebuah
method yang objek tersebut masih ada sifat, ada propertynya
ex
test1 : window1.html
<html>
<head>
<title>Test1</title>
</head>
<body>
<h1> My Window</h1>
</body>
</html>
<head>
<title>Test1</title>
</head>
<body>
<h1> My Window</h1>
</body>
</html>
Test2
: window2.html
<html>
<head>
<title>test2</title>
<script language="javascript">
function buka()
{
myWindow=window.open("window1.html");
}
</script>
</head>
<body>
<input type="button" value="Klik" onclick="buka()" />
</body>
</html>
<head>
<title>test2</title>
<script language="javascript">
function buka()
{
myWindow=window.open("window1.html");
}
</script>
</head>
<body>
<input type="button" value="Klik" onclick="buka()" />
</body>
</html>
contoh lain:
html >
<head>
<title>Untitled Document</title>
<script language="javascript">
function buka()
{
myWindow=window.open("window1.html","myWindow","Width=200,height=500");
}
</script>
</head>
<body>
<input type="button" value="Klik" onclick="buka()" />
</body>
</html>
<head>
<title>Untitled Document</title>
<script language="javascript">
function buka()
{
myWindow=window.open("window1.html","myWindow","Width=200,height=500");
}
</script>
</head>
<body>
<input type="button" value="Klik" onclick="buka()" />
</body>
</html>
OPTION
|
Choice
|
Width
|
# of pixels
|
Height
|
Yes/no –or- 1/0
|
Toolbar
|
-
(back,undo)
|
Status
|
-
|
Menubar
|
-
|
Scrollbar
|
-
(Vertical n
horizontal)
|
Resizeable
|
-
|
Ex
myWindow=window.open(“window1.html”,
”MyWindow”, ”width =100, height=100”);
-OR-
Option
= “width=100,height=100, statuws=0”;
myWindow=window.open(“window1.html”,
“MyWindow”, option);
writing
to document
ex
myWindow=window.open(“ “);
myWindow.documen.write(“This is
My Window”);
myWindow.document.close();
No comments:
Post a Comment