Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Thursday, September 30, 2010

Sortables, Draggables and Droppables

Have you ever thought of having a web page elements that can be sorted, dragged and dropped? Well, thanks to Interface for giving a free plugin for this functionalities. What is Interface then? From Interface website, it is composed of rich interface components utilizing the use of the jQuery - a javascript library. With this collections of components, building web applications and interfaces is as easy as writing javascript with jQuery. Interface has two licenses : MIT license and the GPL, which means that you can use it for both commercial and non-commercial usage all for free as long as you keep the copyright notice in each of Interface's javascript source file.


Wednesday, August 4, 2010

Javascript Floating Images on a Web Page

Here is a javascript code which will make images floating and moving in any direction on your web page. You can see the demo of this functionality at SEMAJ - The Officail Site of James Cuerpo Figues. Notice the two animated butterflies looks like flying around my web page. If you want this on your website, I provided the download link below. Just open the index.html on your browser and you can see the sample page containing floating images. You can copy the codes easily and apply it to your web page if you want.

Download the source code of floating images in zip file by clicking here.

Tuesday, August 3, 2010

PHP Check if Javascipt is Enabled in Browser

Do you want to check in php if javascript is enabled or not? Now, here is a simple trick in php to check if you have javascript enabled in your browser. The trick is that you have a form with a hidden value which will be set as on if it is submitted by a javascript code. Of course, if the form was not submitted, javascript is disabled in your browser. Please read the comments carefully so that you will be guided with the code.


<?php

// this would not work if no html tags
// you can comment the line after this if you already have a open html and body tag
echo '<html><body>';
// stores the value of js if the form is submitted otherwise off
$js = array_key_exists('js', $_POST) ? $_POST['js'] : '';
// if $js is on, the form was submitted by the javascript submit()
if ($js=="on"){
    echo "Javascript is enabled.";
}
// otherwise display the form and try to submit the form with javascript
else{
    echo '<form name="js_form" method="post"><input type="hidden" name="js" value="on"></form>';
    echo '<script type="text/javascript">document.js_form.submit()</script>';
    echo "Javascript is disabled.";
}
// you can comment the line after this if you already have a close body and html tag
echo '</body></html>';

?>