Category: javascript

CSSRefresh, monitorare i files inclusi nelle vostre pagine

Stellar.js, Parallax non č mai stato cosė semplice!

Rilevare il cambiamento dell’orientamento dei dispositivi mobili

Far crashare IE6 con una singola riga di codice Javascript

Convertire XML in JSON con Javascript

Nel tutorial di oggi vedremo come creare una utile funzione Javascript che permette di convertire XML in JSON.

 
// Changes XML to JSON
function xmlToJson(xml) {
 
	// Create the return object
	var obj = {};
 
	if (xml.nodeType == 1) { // element
		// do attributes
		if (xml.attributes.length > 0) {
		obj["@attributes"] = {};
			for (var j = 0; j < xml.attributes.length; j++) {
				var attribute = xml.attributes.item(j);
				obj["@attributes"][attribute.nodeName]

Cercare un numero all’interno di un array in javascript

In questo semplice tutorial javascript venderemo come cercare un numero all’interno di un array.

 
(function () {
 
	// must be sorted array.
	var aList       = [2, 6, 9, 32, 33, 45, 47, 65];
 
		nElemToFind = 6,
		nMinRange   = 0,
		nMaxRange   = aList.length-1,
		bResult     = false;
 
		while (nMinRange < = nMaxRange)
		{
			var nMid = Math.floor((nMinRange + nMaxRange) / 2);
 
			if (nElemToFind === aList[nMid]) {
				bResult = true;
				console.log(bResult)

[jQuery] Eseguire un’azione quando un effetto č stato completato

In questo semplice tutorial vedremo come utilizzare i callbacks nelle animazioni jQuery.

 
$('div').fadeOut(300, function() { $(this).remove(); });
 …

Ottenere il valore di una select box con jQuery

Nel tutorial di oggi vedremo come ottenere il valore selezionato di una select box con jQuery.

 
jQuery.fn.selectedLabel = function()
{
	return this.find(':selected').html();
}
 
Then you can access the text from a selected option within a select:
var text = $('select#month').selectedLabel();
 …

[Javascript] Caricamento in runtime di files js

Nel tutorial di oggi vedremo come caricare in runtime files js e CSS.
Creeremo una funzione che prende in ingresso due parametri, il primo definisce il nome del file, il secondo invece il tipo di file che si intende caricare. Iniziamo!

 
function loadjscssfile(filename, filetype) {
	if(filetype=="js"){ //if filename is a external JavaScript file
  		var fileref=document.createElement('script')
		fileref.setAttribute("type","text/javascript")
  		fileref.setAttribute("src", filename)
 	} else if(filetype=="css"){ //if filename is an external CSS file
  		var fileref=document.createElement("link")
  		fileref.setAttribute("rel", "stylesheet")

Ottenere variabili GET e POST in javascript

Convertire un colore da RGB a esadecimale con jQuery

Nel tutorial di oggi imparerete come creare una funzione che converte un colore RGB in esadecimale utilizzando jQuery.

 
function rgb2hex(rgb) {
 //convert rgb value to hex
 rgb = rgb.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))?\)$/);
 function hex(x) {
  return ("0" + parseInt(x).toString(16)).slice(-2);
 }
 return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
…

Condividi





Booking online




Categorie