CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets matching tags of JavaScript
function IsPageValid() 
{
    var validated = Page_ClientValidate('UserComments');
 
    if (validated) 
    {
        //Its valid
        return true;
    }
    else 
by Egli   Thursday @ 4:04pm
11 Views
no comments
 
$(document).ready(function () {
    if (window.location.protocol == 'https:') {
        $("a[href^='http:\/\/" + window.location.hostname + "']").each(function() { 
               this.href = this.href.replace(/^http:/i, "https:");
           });
    };
});
by Javier Callico   January 24, 2012 @ 7:27am
18 Views
no comments
 
<script type="text/javascript">
 
    function CustomValidatorOmbudsmanNotifiedDate(s, args) {
        var dt = args.Value
 
        if (!dt && $("*[id$='OmbudsmanNotifiedFlag'] input:checked").val() == '1') {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
by Cat   December 12, 2011 @ 3:27pm
46 Views
no comments
 
/*
@ Navigator Detect Function (JavaScript)
@author Luca Provenzano (mailto: hiimluca@gmail.com)
*/
 
function NavDetect(Navegador){
        var Navegador = navigator.appName;
        switch(Navegador){
            case 'Netscape':
            alert('Usted está utilizando Mozilla Firefox o Chrome');
76 Views
no comments
 
/*
@Function NumToBase();
@Exercise JS developed by Luca Provenzano
*/
 
function NumToBase(num, base, prefijo, sufijo){
                var Conversion;
                if (typeof base == 'undefined') base = 16;
                if (typeof prefijo == 'undefined') prefijo = '0x';
                if (typeof sufijo == 'undefined') sufijo = '';
by Luca Provenzano   September 13, 2011 @ 2:58pm
67 Views
no comments
 
<!DOCTYPE html>
<html lang="es">
<head>
    <title>Problema de Física en JS</title>
        <script type="text/javascript">
            //Problema a resolver
            document.write('<p>Sobre un cuerpo de 36 kg que se encuentra en reposo, se aplica una fuerza durante 7 segundos hasta que alcance una velocidad de 21 m/s. <br /> Calcular: <ol><li>Aceleración</li><li>Espacio</li><li>Fuerza aplicada</li><li>Peso</li></ol></p>');
            
            //Datos iniciales a tener en cuenta
            var vi = 0; //Velocidad inicial
94 Views
no comments
 
//get the path name
var sPath = window.location.pathname;
//get the page name with extension
var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
//Show it :)
alert(sPage);
by Egli   September 07, 2011 @ 2:45am
71 Views
no comments
 
//Remember to use Jquery
 
/*
Other options for the popup
window.open('http://www.someurl.com','nameofpopup','height=500,width=400,left=100,top=100,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes');
*/
 
$(function () 
{
  $('.voucherpopup').click(function (event) 
by Egli   August 22, 2011 @ 9:39pm
63 Views
no comments
 
C#
//using System.Web.UI
//.aspx page must have a reference to jquery (for the example described bellow)
 
string someScript= " $(window).bind('load', CodeToExcecute());";
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "someScript", someScript, true);
by Egli   August 04, 2011 @ 1:40am
99 Views
no comments
 
<?php
 
/*php提供的URL编码函数是基于字节的对由ie的javascript函数escape编码的数据就无能为力了。*/
 
function escape($str) {
    preg_match_all("/[\x80-\xff].|[\x01-\x7f]+/", $str, $r);
    $ar = $r[0];
    foreach($ar as $k=>$v) {
        if(ord($v[0]) < 128)
            $ar[$k] = rawurlencode($v);
by clark   August 01, 2011 @ 4:04am
107 Views
no comments
 
//You need to reference Jquery for this .js script to work
//This will execute once the page has loaded
$(window).bind("load", function() 
{
   // code here
});
by Egli   July 27, 2011 @ 3:52am
99 Views
no comments
 
<html>
<head>
<script type="text/javascript"> 
 var chldWnd;
 function OpenChild(){
  chldWnd = window.open("http://www.google.com", "popup","height=190,width=190");
  chldWnd.focus();
  }
 
by biboyatienza   June 16, 2011 @ 11:47pm
128 Views
no comments
 
function checkEmail(inputvalue){    
    var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
    if(pattern.test(inputvalue)){         
        return true;   
    }else{   
        return false; 
    }
}
by jaredmroberts   January 28, 2011 @ 2:52pm
174 Views
no comments
 
<script type="text/javascript">
 
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'SOME-Code-Here']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
by Corey Gaudin   January 24, 2011 @ 8:19am
158 Views
no comments
 
Genel kullandığım db fonksiyonları
 
$table sadece table adı olabildiği gibi genelde eğer $where  false verilirse sorgu 
değişkeni olarak da kullanılabilir.
 
dbDelete fonksiyonu kesinlikle $where bekler. Bilirsiniz SQL en çok update ve delete'de 
where kullanılmadan oluşan hatalara açık olduğundan eleştirilir. Program tarafında kendimi
 güvene almak istedim  (bu yanlış silme ve güncellemeyi 2 kez yaşadım, korkusu yeter :) ).
 
Fonksiyonlarıma genelde dönüş değerlerine göre isim veririm. Mesela dbResult tek sonuç döner, 
by erkin   January 07, 2011 @ 1:28am
174 Views
no comments
 
var logTailId = -1;
 
$(document).ready(function () {
    $('#tail').click(function () {
        var $tail = $(this);
        if ($tail.text().indexOf('Stop') >= 0) {
            $tail.text('Tail...');
            clearTimeout(logTailId);
        }
        else {
by kenwiebke   December 19, 2010 @ 5:43pm
215 Views
no comments
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>Untitled Page</title>
 
    <script type="text/javascript">
 
     //For more info http://www.ics.uci.edu/~eppstein/numth/frap.c
 
      function FindApproximation(numberToApprox, maxDenominator)
by Jason Rowe   December 13, 2010 @ 4:22pm
200 Views
no comments
 
C#
[Mixin("String.prototype")]
public static class StringExtensions
{
    public static bool StartsWith(string value)
    {
        return ((string)Script.Literal("this")).IndexOf(value) == 0;
    }
}
by Bruno Figueiredo   October 13, 2010 @ 2:47pm
303 Views
1 comments
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Html Template</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 
    <style type="text/css">
        .primary { background-color: green; }
        .secondary { background-color: blue; }
by jwwishart   June 16, 2010 @ 4:02pm
783 Views
no comments
 
// Iphone Javascript Clock
var timerID = null;
var timerRunning = false;
function stopclock() {
    if (timerRunning)
        clearTimeout(timerID);
    timerRunning = false;
}
function showtime() {
    var timeValue;
by Arjan   May 18, 2010 @ 5:40am
192 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate