Format:
Recent snippets matching tags of Javascript
//******************************// //Prevent wrong input for mobile //******************************// $("#Mobile").keydown(function (event) { // Allow: backspace, delete, tab and escape if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || // Allow: Ctrl+A (event.keyCode == 65 && event.ctrlKey === true) || // Allow: home, end, left, right
10 Views
no comments
var baseUrl; var applicationUrl; baseUrl = document.location.href; baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf('/')); applicationUrl = baseUrl.substring(0, baseUrl.lastIndexOf('/'));
17 Views
no comments
//start processing var api = new moviesApi(); api.getRatings({ success: function (result) { for (var i = 0; i < result.length; i++) { //new Option(text, value) var option = new Option(result[i].ID, result[i].Name); $('#ratings').append( $('<option></option>').val(result[i].ID).html(result[i].Name) );
22 Views
no comments
displayError = function (result) { $('#errorDisplay').show(); $('#errorDisplay').html(result.responseText); }
31 Views
no comments
<%@ Page Title="" Language="C#" MasterPageFile="~/Miso1.Master" AutoEventWireup="true" CodeBehind="Currency.aspx.cs" Inherits="WebApplication1.Currency" %> <asp:Content ID="Content1" ContentPlaceHolderID="cphHead" runat="server"> <script type="text/javascript" language="javascript"> $(document).ready(function () { }); String.prototype.replaceAll = function (str1, str2, ignore) { return this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof (str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2);
46 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></title> <script type="text/javascript" src="JavaScript/jquery-1.4.1.min.js"></script> <script type="text/javascript" language="javascript"> String.prototype.replaceAll = function (str1, str2, ignore) {
33 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></title> <script type="text/javascript" src="JavaScript/jquery-1.4.1.min.js"></script> <script type="text/javascript" language="javascript"> String.prototype.replaceAll = function (str1, str2, ignore) {
39 Views
no comments
ajaxCallMethod("CallbackHandler.ashx?", "Test", [{ Entered: "03/15/2010", Name: "Rick"}], function (result) { alert(result); }); ajaxCallMethod("CallbackHandler.ashx?", "Test", [{ Entered: new Date(2010,2,15), Name: "Rick"}], function (result) { alert(result); });
57 Views
no comments
using System; using System.Net.Http.Formatting; using System.Threading.Tasks; using System.Web.Script.Serialization; using System.Json; using System.IO; namespace Westwind.Web.WebApi { public class JavaScriptSerializerFormatter : MediaTypeFormatter
386 Views
no comments
function IsPageValid() { var validated = Page_ClientValidate('UserComments'); if (validated) { //Its valid return true; } else
69 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:"); }); }; });
46 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;
85 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');
111 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 = '';
92 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
143 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);
101 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)
90 Views
no comments
//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);
136 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);
140 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 });
137 Views
no comments
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search
