Archive

Archive for July, 2009

How to disable page printing

July 27, 2009 Leave a comment

To disable body content in print add this style in head.
<style media=”print”>
body{
display:none;
}
</style>

Tested: ff 3.0.12,ie 7.0, chrome 1.0, sfari 3.2.1, opera 9.64

Disable Context Menu

July 24, 2009 Leave a comment

To disable mouse right click use this code in body tag
<body oncontextmenu=”return false”>

To disable copy paste use this in body tag
<body ondragstart=”return false” onselectstart=”retturn false”>

Tested: ff 3.0.12,ie 7.0, chrome 1.0, sfari 3.2.1, opera 9.64

Dragable Div

July 21, 2009 Leave a comment

<html>
<head>
<title>BASIC DRAG-AND-DROP DIVS</title>
<script language=”javascript”>
// start dragging
function startDrag(e){
// determine event object
if(!e){var e=window.event};
// determine target element

var targ=e.target?e.target:e.srcElement;

if(targ.className!=’draggable’){return};
// calculate event X,Y coordinates
offsetX=e.clientX;
offsetY=e.clientY;
// assign default values for top and left properties
if(!targ.style.left){targ.style.left=’0px’};
if(!targ.style.top){targ.style.top=’0px’};
// calculate integer values for top and left properties
coordX=parseInt(targ.style.left);

coordY=parseInt(targ.style.top);

drag=true;

// move div element

document.onmousemove=dragDiv;

}

// continue dragging

function dragDiv(e){

if(!drag){return};

if(!e){var e=window.event};

var targ=e.target?e.target:e.srcElement;

// move div element

targ.style.left=coordX+e.clientX-offsetX+’px’;

targ.style.top=coordY+e.clientY-offsetY+’px’;

return false;

}

// stop dragging

function stopDrag(){

drag=false;

}

window.onload=function(){

document.onmousedown=startDrag;

document.onmouseup=stopDrag;

}

</script>

<style type=”text/css”>

.draggable {

position: relative;

width: 250px;

height: 200px;

background-color: #ccc;

border: 1px solid #000;

}

</style>

</head>

<body>

<div class=”draggable”>

This is a dragging DIV element

</div>

<div class=”draggable”>

This is a dragging DIV element

</div>

<table border=”45″ cellpadding=”12″ cellsacing=”12″>

<tr ><td>djfdskjf</td><td >djfdskjf</td></tr>

<tr class=”draggable”><td >djfdskjf</td><td >djfdskjf</td></tr>

<tr><td class=”draggable”>djfdskjf</td><td >djfdskjf</td></tr>
<tr><td class=”draggable”>djfdskjf</td><td >djfdskjf</td></tr>
</body>
</html>

Categories: Javascript

Get all table name from a database

July 9, 2009 Leave a comment

String mysql_tablename(resource $result,  int $i)

<?php

mysql_connect(“localhost”,  “root”,  “password”);

$resutl = mysql_list_tables(“database”);

$num_rows = mysql_num_rows($result);

for($i = 0; $i < $num_rows; $i++){

 echo “Table”, mysql_tablename($result,  $i), “<br/>”;

}

mysql_free_result($result);

?>

Categories: php
%d bloggers like this: