SORU
15 ŞUBAT 2009, Pazar


Nasıl Javascript betiği sonlandırmak için

Çok PHP gibi js komut çıkış yapacak bir kod I neeed '' veya ''. ölmek çıkış (En iyi programlama uygulama biliyorum ama buna ihtiyacım var).

CEVAP
15 ŞUBAT 2009, Pazar


JavaScript equivalent for PHP's die. BTW sadece exit() (teşekkürler splattne) çağırır:

function exit( status ) {
    // http://kevin.vanzonneveld.net
    //     original by: Brett Zamir (http://brettz9.blogspot.com)
    //        input by: Paul
    //     bugfixed by: Hyam Singer (http://www.impact-computing.com/)
    //     improved by: Philip Peterson
    //     bugfixed by: Brett Zamir (http://brettz9.blogspot.com)
    // %        note 1: Should be considered expirimental. Please comment on this function.
    // *     example 1: exit();
    // *     returns 1: null

    var i;

    if (typeof status === 'string') {
        alert(status);
    }

    window.addEventListener('error', function (e) {e.preventDefault();e.stopPropagation();}, false);

    var handlers = [
        'copy', 'cut', 'paste',
        'beforeunload', 'blur', 'change', 'click', 'contextmenu', 'dblclick', 'focus', 'keydown', 'keypress', 'keyup', 'mousedown', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'resize', 'scroll',
        'DOMNodeInserted', 'DOMNodeRemoved', 'DOMNodeRemovedFromDocument', 'DOMNodeInsertedIntoDocument', 'DOMAttrModified', 'DOMCharacterDataModified', 'DOMElementNameChanged', 'DOMAttributeNameChanged', 'DOMActivate', 'DOMFocusIn', 'DOMFocusOut', 'online', 'offline', 'textInput',
        'abort', 'close', 'dragdrop', 'load', 'paint', 'reset', 'select', 'submit', 'unload'
    ];

    function stopPropagation (e) {
        e.stopPropagation();
        // e.preventDefault(); // Stop for the form controls, etc., too?
    }
    for (i=0; i < handlers.length; i  ) {
        window.addEventListener(handlers[i], function (e) {stopPropagation(e);}, true);
    }

    if (window.stop) {
        window.stop();
    }

    throw '';
}

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • MotoManTV

    MotoManTV

    10 Aralık 2009
  • parlophone

    parlophone

    28 ŞUBAT 2006
  • TopOfTheTech

    TopOfTheTech

    5 NİSAN 2010