Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

About this user

Soul http://www.harpra.com

« Newer Snippets
Older Snippets »
10 total  XML / RSS feed 

Redirect after 5 seconds

<HTML>
<HEAD>
  <TITLE>Redireccionado</TITLE> 
  <SCRIPT LANGUAGE="JavaScript">
  function redireccionar() {
    setTimeout("location.href='articulo.php?id=tw_redireccion'", 5000);
  }
  </SCRIPT>
</HEAD>
<BODY onLoad="redireccionar()">
<P>Bla, bla, bla,...
</BODY>
</HTML>

Validate a email

function validEmail(email) {
  var emailReg = "^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,4}$";
  var regex = new RegExp(emailReg);
  return regex.test(email);
}

Creating nodes with Javascript DOM

    var newa=document.createElement('a');
    newa.className="class";
    var newimg=document.createElement('img');
    newimg.src="./image.png";
    newimg.alt="Image name";
    newimg.className="Image class";
    newa.appendChild(newimg);
    newa.href="#";

Validate a url

function validarURL(valor){
  if (/^w+([.-]?w+)*.w+([.-]?w+)*(.w{2,3})+$/.test(valor)){
   return (true)
  } else {
    return (false);
  }
}

Show fields from a Mysql table

SHOW FIELDS FROM `$bd_tabla`

Show tables from a MySQL database

SHOW [FULL|OPEN] TABLES [FROM db_name] [LIKE 'pattern']

Show databases from a MySql Server

SHOW {DATABASES | SCHEMAS} [LIKE 'pattern']

CSS IE hack

p a {
     background-color:blue
}

p > a{
     background-color:red
}


In IE we will see a blue red link.

A "interesant" layout

div.container{
background:#fff;
border:1px solid #8E221B;
margin:0 auto;
width:60%;
height:100%;
 
}
html > body div.container{
min-height:100%;
}


This css code explands de "container" div. It simulates old table layouts with 100% height.

Creating Excel files from php

We must use this header.
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=excel.xls");


An then, show the html table
« Newer Snippets
Older Snippets »
10 total  XML / RSS feed