Auto refresh div with jQuery
This script will automatically load and refresh a div. It loads the data from a file.
First you need to include jQuery on your page .. Load jQuery from google
Then use this:
[code lang="javascript"]
[/code]
This will update “infoDiv” every 1000 milliseconds with new data from data.php
If you create the data.php file, write a line and save it, it should appear on your main page.
Hash generator
Need to generate a md5/sha1/whatever hash ? Use the powerfull hash generator at this page.
Remember: we do not save or archive generated hashes.
Toogle visibility (show/hide) on a DIV (html object) with Javascript
The following script works in:
FF 3
IE 5.5,6,7,8
IE 8
Crome 2
[code lang="javascript"]
[/code]
A little example is here:
[code lang="html"]
Gå væk
[/code]
If you want it to start out hidden you can either set the visibility tag manually, or you can simply just insert:
[code lang="javascript"]
[/code]
Next to the div-tag in your HTML.
Javascript function for validating an email
[code lang="javascript"]
function echeck(email)
{
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
return reg.test(email);
}
[/code]
Javascript function for counting words
function countwords(str)
{
return str.replace(/ +/gi,' ').replace(/(^\s*)|(\s*$)/gi,'').split(' ').length;
}
Div + TextArea 100% Height (Also in IE without Quirksmode)
I needed this for a Wordpress plugin, so i will use the code from WP as an Example.
Basicly we have to make sure that all the divs around our textbox at using up all the vertical space posible, otherwise our 100% will refer to the nearest (smallest) sourounding div.
First some CSS
[code lang="css"]
#wpwrap, #wpcontent,#wpbody,#wpbody-content
{
height: 90%;
}
#editorcontainer, #phped
{
margin: 0px;
margin-top: 0px;
margin-bottom: 0px;
margin-left: 0px;
margin-right: 0px;
padding: 0px;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
border: 0px solid black;
}
#phped
{
border: 1px solid black;
}
[/code]
The first block are the sourrounding divs, the next is the nearest sourounding div and the textarea itself, finaly i add a border to the textarea.
The HTML/Javascript then goes like:
[code lang="html"]
[/code]
It works but i probably breaks every standard in the book
Jeg har testet det i Firefox, Chrome og Internet Explorer.
Quick-fix for Debian 4.0 Image on Citrix Xenserver
You need to update the GPG key for the xenservere repository:
apt-get update
apt-get upgrade
wget -O – http://updates.xensource.com/XenServer/RPM-GPG-KEY-5.5.0 |apt-key add
apt-get update
apt-get upgrade
Codesnippets.dk – now in English
The first commenter ever on this, used to be, Danish website wrote to us in English. So we made a quick decision to change the language of the site to English. Which we have done by now, all new posts should be in English and older posts are about to be translated.
So please, speak English, and be international. We like to help each other.
Disclaimer: Something might still be in Danish, if we to translate anything please tell us and we will get it done asap.
We still use the Danish version of Gpl v3.0, because the server are located in Denmark we belive that this is the best way to ensure that the license are legally covered according to local jurisdiction.
phpinfo() in existing html-code
Snippet to include phpinfo() in already existing html. Strips unnecessary html and css:
Read the rest of this entry »
Load jQuery from Google
Here is a snippet, which you can include in your HTML header, to load jQuery directly from Google. This saves you a little traffic, since the script is pulled from Google’s servers, and you don’t have to copy jQuery every time you start a new site.
Read the rest of this entry »