window.close method

Sample Code for window.close()

<html>
<head>
<title>JavaScript Window Close Example </title>
</head>
<SCRIPT language="JavaScript1.2">
function popuponclick()
{
my_window = window.open("",
"mywindow","status=1,width=350,height=150");
my_window.document.write('<H1>The Popup Window</H1>');
}
function closepopup()
{
if(false == my_window.closed)
{
my_window.close ();
}
else
{
alert(‘Window already closed!’);
}
}
</SCRIPT>
<body>
<P>
<A href="javascript: popuponclick()">Open Popup Window</A>
</P>
<P>
<A href="javascript: closepopup()">Close the Popup Window</A>
</P>
</body>
</html>

use something like this for waiting # sec before loading url link.

<BODY>
<script type=text/javascript>
function goNow() {
document.location=_l;
}
function setUp() {
setTimeout(“goNow()”,_time); // 3 seconds delay
}
var _l = “http://www.urlhere.com/”;
var _time = 3000; // msecs.
onLoad=’setUp()’;
</script>

</BODY>

referring info at this page:
http://www.js-examples.com/example/?ex=272

The action page (after processing the form) should generate html like this:

<html>
<head>
<script type=”text/javascript“>
if (window.opener && !window.opener.closed) window.opener.location.href=”successpage.htm”;
window.close();
</script>
</head>
<body>
</body>
</html>

But I prefer to display the success page in the popup itself:

<html>
<head>
</head>
<body onload=”setTimeout(‘window.close()’, 3000)”>
The page has been successfully processed.
<form>
<input type=”button” value=”Close” onclick=”window.close()”>
</form>
</body>
</html>

If you want to do something in the main window (like reload it or navigate to another url)

<html>
<head>
<script type=”text/javascript“>
function doClose(){
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
//or
//window.opener.location.href=”somepage.htm”;
}
window.close();
}
</script>
</head>
<body onload=”setTimeout(‘doClose()’, 3000)”>
The page has been successfully processed.
<form>
<input type=”button” value=”Close” onclick=”doClose()”>
</form>
</body>
</html>

I used the following code on the success page, works like a charm. It even recognized that the referring window was the iframe from the parent page and loaded the successdefault.html into the iframe as it should Thanks again!

<head>

<script type=”text/javascript“>
function doClose(){
if (window.opener && !window.opener.closed) {
//window.opener.location.reload();
//or
window.opener.location.href=”successdefault.html”;
}
window.close();
}
</script>

</head>

<body onLoad=doClose()>

The action page (after processing the form) should generate html like this:

<html>
<head>
<script type=”text/javascript“>
if (window.opener && !window.opener.closed) window.opener.location.href=”successpage.htm”;
window.close();
</script>
</head>
<body>
</body>
</html>

But I prefer to display the success page in the popup itself:

<html>
<head>
</head>
<body onload=”setTimeout(‘window.close()’, 3000)”>
The page has been successfully processed.
<form>
<input type=”button” value=”Close” onclick=”window.close()”>
</form>
</body>
</html>

If you want to do something in the main window (like reload it or navigate to another url)

<html>
<head>
<script type=”text/javascript“>
function doClose(){
if (window.opener && !window.opener.closed) {
window.opener.location.reload();

function DoSomething()
{
var outW = window.open(“”, “newwin”, “top=250, left=250, height=150, width=300″);
outW.document.write(“<HTML>”)
outW.document.write(“<TITLE>Confirmation</TITLE>”);
outW.document.write(“<body onload=’setTimeout(‘window.close()”, 5000>”);
outW.document.write(“<font color=#0000CC>”);
outW.document.write(“<div align=center><strong>Thank You”);
outW.document.write(“<P>Your Information has been received.</P></strong></div></font>”);
outW.document.write(“</body></HTML>”);
window.close();
//outW= window.setTimeout(document.close(), 2000);
}
//or
//window.opener.location.href=”somepage.htm”;
}
window.close();
}
</script>
</head>
<body onload=”setTimeout(‘doClose()’, 3000)”>
The page has been successfully processed.
<form>
<input type=”button” value=”Close” onclick=”doClose()”>
</form>
</body>
</html>

You have nested quotes and invalid <body> tag.

function DoSomething()
{
var outW = window.open(“”, “newwin”, “top=250, left=250, height=150, width=300″);
outW.document.write(“<HTML>”)
outW.document.write(“<TITLE>Confirmation</TITLE>”);
outW.document.write(“<body onload=\”setTimeout(‘window.close()’, 5000)\”>”;
outW.document.write(“<font color=#0000CC>”);
outW.document.write(“<div align=center><strong>Thank You”);
outW.document.write(“<P>Your Information has been received.</P></strong></div></font>”);
outW.document.write(“</body></HTML>”);
outW.document.close();
window.close();
}

PeMbulatan pHp

mod

netslr=567888
sisa=MOD(netslr,100)
bayar=netslr-sisa
dibulatkan ke atas bila sisa lebih dari 50
kurang=100-sisa
bayar=netslr+(sisa+kurang)

or

etslr=567888
sisa=MOD(netslr,100)
?sisa —> hasilnya 88
bayar=netslr-sisa
?bayar —> hasilnya 567800

atau
netslr=567888
sisa=MOD(netslr,100)
bayar=netslr+(100-sisa)

sTring Php

Fungsi string adalah fungsi yang mengolah kata atau huruf. Fungsi-fungsi tersebut sebagai berikut:

  1. addslashes(string) : menambahkan tanda slash (/) jika mengandung karakter tanda petik satu (‘), tanda petik dua (“) dan backslash (\).Contoh:<?php
    $str = "Is your name O'reilly?";
    // Outputs: Is your name O\'reilly?
    echo addslashes($str);
    ?>
  2. explode(separator, string): menampilkan array dari sebuah string dengan cara memilah kalimat berdasarkan separator yang diberikan.Contoh:<?php
    // Contoh 1
    $pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
    $pieces = explode(" ", $pizza);
    echo $pieces[0]; // piece1
    echo $pieces[1]; // piece2

    // Contoh 2
    $data = “foo:*:1023:1000::/home/foo:/bin/sh”;
    list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(“:”, $data);
    echo $user; // foo
    echo $pass; // *

    ?>

  3. htmlentities(string): mengkonversi bentuk html ke dalam bentuk entiti html.Contoh:<?php
    $str = "A 'quote' is <b>bold</b>";

    // Outputs: A ‘quote’ is <b>bold</b>
    echo htmlentities($str);
    ?>

  4. ltrim(string), rtrim(string), trim(string): masing-masing menghapus karakter kosong di sebelah kiri, disebelah kanan dan di sebelah kiri dan kanan.Contoh:<?php

    $text = “\t\tThese are a few words :) … “;
    $trimmed = ltrim($text);
    // $trimmed = “These are a few words :) … “
    $trimmed = ltrim($text, ” \t.”);
    $trimmed = rtrim($text);
    // $trimmed = "\t\tThese are a few words :) ..."
    echo trim($text); // "These are a few words :) ..."
    echo trim($text, " \t."); // "These are a few words :) "

    ?>

  5. md5(string): menghitung hasil md5 dari sebuah karakterContoh:<?php
    $str = 'apple';

    if (md5($str) === ‘1f3870be274f6c49b3e31a0c6728957f’) {
    echo “Would you like a green or red apple?”;
    exit;
    }
    ?>

  6. nl2br(string): mengkonversi baris baru menjadi kode html <br>Contoh:<?php
    echo nl2br("foo isn't\n bar");
    ?>

    Outputnya akan menjadi:

    foo isn't<br />
  bar
  1. print(string), echo(string): sama-sama berfungsi mencetak teks ke browser
  2. str_str(string_kalimat, string_kata_yang_dicari): mencocokkan kata yang dicari dengan yang ada dalam kalimatContoh:<?php
    $email = 'user@Contoh.com';
    $domain = strstr($email, '@');
    echo $domain; // prints @Contoh.com
    ?>
  3. str_replace(string_kata_yang_dicari, string_pengganti, kalimat): mengganti kata yang cocok dengan yang dicari dalam kalimatContoh:<?php
    // Provides: <body text='black'>
    $bodytag = str_replace("%body%", "black", "<body text='%body%'>");

    // Provides: Hll Wrld f PHP
    $vowels = array(“a”, “e”, “i”, “o”, “u”, “A”, “E”, “I”, “O”, “U”);
    $onlyconsonants = str_replace($vowels, “”, “Hello World of PHP”);

    // Provides: You should eat pizza, beer, and ice cream every day
    $phrase = “You should eat fruits, vegetables, and fiber every day.”;
    $healthy = array(“fruits”, “vegetables”, “fiber”);
    $yummy = array(“pizza”, “beer”, “ice cream”);

    $newphrase = str_replace($healthy, $yummy, $phrase);
    ?>

  4. strip_tags(string, tag_yang_dibolehkan): menghapus semua tag html dalam sebuah kalimat.Contoh<?php
    $text = '
    <p>Test paragraph.</p>
    <!-- Comment -->
    Other text';
    echo strip_tags($text);

    echo “\n\n——-\n”;

    // allow <p>
    echo strip_tags($text, ‘<p>’);
    ?>

    Outputnya:

    Test paragraph.
   Other text

   -------

   <p>Test paragraph.</p>

   Other text
  1. stripslashes(string): menghapus tanda backslash (\) dalam sebuah kalimatContoh:<?php
    $str = "Is your name O\'reilly?";

    // Outputs: Is your name O’reilly?
    echo stripslashes($str);
    ?>

  2. strlen(string): menghitung panjang kalimatContoh:<?php
    $str = 'abcdef';
    echo strlen($str); // 6

    $str = ‘ ab cd ‘;
    echo strlen($str); // 7
    ?>

  3. strtolower(string): membuat kalimat menjadi huruf kecil semuaContoh:<?php
    $str = "Mary Had A Little Lamb and She LOVED It So";
    $str = strtolower($str);
    echo $str; // Prints mary had a little lamb and she loved it so
    ?>
  4. strtoupper(string): membuat kalimat menjadi huruf besar semuaContoh:<?php
    $str = "Mary Had A Little Lamb and She LOVED It So";
    $str = strtoupper($str);
    echo $str; // Prints MARY HAD A LITTLE LAMB AND SHE LOVED IT SO
    ?>
  5. ucfirst(string): membuat awalan kalimat menjadi huruf kapitalContoh:<?php
    $foo = 'hello world!';
    $foo = ucfirst($foo); // Hello world!

    $bar = ‘HELLO WORLD!’;
    $bar = ucfirst($bar); // HELLO WORLD!
    $bar = ucfirst(strtolower($bar)); // Hello world!
    ?>

  6. ucwords(string): membuat semua awalan kata dalam kalimat menjadi huruf kapitalContoh:<?php
    $foo = 'hello world!';
    $foo = ucwords($foo); // Hello World!

    $bar = ‘HELLO WORLD!’;
    $bar = ucwords($bar); // HELLO WORLD!
    $bar = ucwords(strtolower($bar)); // Hello World!
    ?>

  7. wordwrap(string): menggulung kalimat sesuai dengan banyak karakter maksimum yang diperbolehkan dalam satu barisContoh:<?php
    $text = "The quick brown fox jumped over the lazy dog.";
    $newtext = wordwrap($text, 20, "<br />\n");

    echo $newtext;
    ?>