Information Computer

Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Friday, August 5, 2011

JavaScript PopUp Window

sometimes if we create a web we will need something called a popup window. popup window is used to bring up a web page in a new window whose size can be set. we can make a popup using javascript. The following source code to create a popup window with javascript.

Create a file with the name index.php

<html>
<head>
<title>PopUp Window</title>
<script>
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page"+id+"=window.open(URL,'"+id+"', 'toolbar=0, scrollbars=0, location=0, statusbar=0, menubar=0, resizable=0, width=250, height=250, left =304,top = 150.5');");
}
</script>
</head>
<body>
<a href="javascript:popUp('popup.html')">popup</a>
</body>
</html>

nb : for green text should be in a row (do not use the enter key).

then make more of a web page for pages that appear in a popup window with the name popup.html .

<html>
<head>
<title>popup</title>
</head>
<body>
PopUp Window
</body>
</html>

That simple example of using a popup window with javascript. may be useful. thank :)


need to know! 
Pop-up ads or pop-ups are a form of online advertising on the World Wide Web intended to attract web traffic or capture email addresses. Pop-ups are generally new web browser windows to display advertisements. The pop-up window containing an advertisement is usually generated by JavaScript, but can be generated by other means as well.

A variation on the pop-up window is the pop-under advertisement, which opens a new browser window hidden under the active window. Pop-unders do not interrupt the user immediately and are not seen until the covering window is closed, making it more difficult to determine which web site opened them.
READ MORE >> JavaScript PopUp Window

Thursday, August 4, 2011

ASCII Code With JavaScript

this time I will try to explain about how to find the ASCII code keyboard with javascript. so when we typed one key on the keyboard will display a message box that displays the number or the ASCII code of the key. I'll give the source code of a simple javascript. for more details, please see the source code.

<head>
<script LANGUAGE="JavaScript">
function tampil(e)
{
alert(e.keyCode);
}
</script>
</head>
<body onload='document.getElementById("nama").focus()'>
<label>type here :</label>
<input type="text" id="nama" size="15" onKeyUp="tampil(event);"><br>
</body>

that's the way to find out the ASCII code of the keyboard keys we press with JavaScript. ask if anyone in the written comments below. thank :)

need to know! 
The American Standard Code for Information Interchange (ASCII) is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text. Most modern character-encoding schemes are based on ASCII, though they support many more characters than ASCII does.

US-ASCII is the Internet Assigned Numbers Authority (IANA) preferred charset name for ASCII.

Historically, ASCII developed from telegraphic codes. Its first commercial use was as a seven-bit teleprinter code promoted by Bell data services. Work on ASCII formally began on October 6, 1960, with the first meeting of the American Standards Association's (ASA) X3.2 subcommittee. The first edition of the standard was published during 1963, a major revision during 1967, and the most recent update during 1986. Compared to earlier telegraph codes, the proposed Bell code and ASCII were both ordered for more convenient sorting (i.e., alphabetization) of lists and added features for devices other than teleprinters.

ASCII includes definitions for 128 characters: 33 are non-printing control characters (now mostly obsolete) that affect how text and space is processed; 95 are printable characters, including the space, which is considered an invisible graphic. The most commonly used character encoding on the World Wide Web was US-ASCII until December 2007, when it was surpassed by UTF-8.
READ MORE >> ASCII Code With JavaScript

Tuesday, August 2, 2011

Ajax Javascript

May still be many who do not know what it was ajax. I think ajax is a web-based programming techniques used to create an interactive web application. Ajax is a combination of server side scripting and client side scripting. so ajax is some combination of Web programming such as javascript, PHP, DOM, HTML, and others.

ajax point will update the contents of a web without reloading process. ajax will do so working in an asynchronous data exchange. please note the exchange of data has 2 post and get methods. ajax script this time using two methods. The following examples use the ajax script.

if you try this script at home. Your computer must be installed xampp as a stand-alone server (localhost).

script file index.php

<html>
<head>
<script src=ajax.js></script>
</head>
<body>
<input type=text id=nama >
<input type=submit onclick=kirim("POST") value=POST>
<input type=submit onclick=kirim("GET") value=GET><br>
<div id=hasil />
<body>
</html>

script file ajax.js

var ajax;
if(window.ActiveXObject){
    ajax = new ActiveXObject("MicrosoftXMLHTTP");
}else {
    ajax = new XMLHttpRequest();
}

function proses(metode,url,params,id,output) {
    if (metode == 'POST'){
        ajax.open("POST",url,true);
        ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    }else{
        ajax.open("GET",url+'?'+params,true);
        params = null ;
    }
    ajax.onreadystatechange = function Response(){
        respon =  ajax.responseText;
        obj = document.getElementById(id) ;
        switch(output){
            case 'innerHTML' : obj.innerHTML = respon;
                break ;
        }
    }
    ajax.send(params);
}

function kirim(metode){
    id = "hasil" ;
    output = 'innerHTML' ;
    nama = document.getElementById('nama').value ;
    url = "ajax.php";
    var params = "nama="+escape(nama);

    proses(metode,url,params,id,output);
}

script file ajax.php

<?php
    if(isset($_POST['nama'])){
        $text1 = $_POST['nama'];
        echo $text1." <i>metode post</i>" ;
    }else if(isset($_GET['nama'])){
        $text2 = $_GET['nama'];
        echo $text2." <i>metode get</i>" ;
    }else{
        echo "null";
    }
?>

create a third file, and be simple ajax. thank :)
READ MORE >> Ajax Javascript

Followers