Archive for the ‘HTML’ Category

<style type="text/css">
tr.s1{ background-color: #e0e0e0; color: black; }
tr.s2{ background-color: #ffffff; color: black; }
<tr class="s1"><td>ciao</td><td>come</td></tr>
<tr class="s2"><td>stai</td><td>io</td></tr>
<tr class="s1"><td>bene</td><td>grazie</td></tr>
<tr class="s2"><td>saluti</td><td>ciao</td></tr>

Read Full Post »

Suppose you have a block of text you want to be collapsible clicking a link.
Here is the code:

<script language="javascript">
  function switchDiv(id_div)
    if(document.getElementById(id_div).style.display == 'none')
   document.getElementById(id_div).style.display = 'block';
   document.getElementById(id_div).style.display = 'none';

Read Full Post »

Page Redirect in Html or JavascriptThere are 2 methods to redirect html pages.

The first one is pure HTML.
The second one is done with Javascript.

HTML Method

insert this line inside the
<head> ... </head>

<meta http-equiv="refresh" content="num_sec; URL=new_web_address">


  • num_sec is the number of seconds to wait before redirection
  • new_web_address is the new relative or absolute URL where to go

Some (old) browsers do not interpret this meta so always remember to add a visual hyperlink to the same page where to redirect in some well visible portion of the page like this:

<a href="new_web_address">Click here if you are not automatically redirected to page num_sec before new_web_address seconds.</a>

Pro: it works even if Javascript is disabled

Vs: some old browsers do not interpret it

Javascript Method

If you want to redirect immediately to the new page, add this 5 lines after the <head> tag:

<script language="javascript" type="text/javascript">
// -->

If you want to redirect to the new page but only after the old page was displayed for at least num_sec seconds add this lines after the final </html> tag:

<script language="javascript" type="text/javascript">
window.setTimeout('window.location="new_web_address"; ', num_sec*1000);
// -->

Read Full Post »