I just found out that toggle() is not working with the JQuery version I've been using. I am using 1.72 from this link.
After switching to version 1.80, I now can lay back a bit by enjoying the convenience of toggle() function which requires many lines of codes if using javascript to control the visibility of an element.
Silly me. ;...
Sunday, August 26, 2012
Tuesday, August 21, 2012
Simple HTML/Javascript Codes to Display your Live Mouse Coordinates (Firefox Fix)
The firefox friendly version:
<html>
<head>
<script type="text/javascript">
var ff = (navigator.userAgent.indexOf("Firefox") != -1);
function showXY(e)
{
if (ff) {
var s = 'X=' + e.pageX + ' Y=' + e.pageY;
document.getElementById('coordinates').textContent = s;
}
else {
var s = 'X=' + window.event.clientX + ' Y=' + window.event.clientY;
...
Monday, August 20, 2012
Simple HTML/Javascript Codes to Display your Live Mouse Coordinates
Here they are:
<html>
<head>
<script type="text/javascript">
function showXY()
{
var s = 'X=' + window.event.clientX + ' Y=' + window.event.clientY;
document.getElementById('coordinates').innerText = s;
}
</script></head>
<body onmousemove=showXY()>
<div id="coordinates"></div>
</body>
</html>
The key component for this to work is highlighted in green.
However this won't work in Firefox....
Weird Chrome Javascript Problem
I encounter this today that the Javascript var top cannot be used in Chrome.
Weird. It works well in Safari and IE. In Chrome, the variable name is stored as [Object Window].
Solution: Just rename top variable to something else...
PHP to Replace Last Character in a String
Seems like a trivial code but it's nice to put it here as I tend to forgot the syntax from time to time:
$line = preg_replace("/\n$/","",$line); // To replace last newline character
$line = preg_replace("/\r\n$/","",$line); // To replace last newline character in Windows environment
$line = preg_replace("/\s$/","",$line); // To replace last space in a string
Assuming your string is stored in $line...
Sunday, August 5, 2012
Protect Your CSS and Javascript Codes

Update 20th of March 2013: Here's a updated version to include a simple minification before sending your Javascript / CSS codes to the browser especially Chrome:
http://webtrick101.blogspot.com/2013/03/protect-your-external-css-and.html
Actually there is no 100% way to protect your CSS and Javascript codes as if the person who intended to copy is using Google Chrome browser, your codes will be...
Saturday, August 4, 2012
Setting Permission for PHP/IIS Environment Especially When PHP Temporary File Facility Is Used

When PHP is run on IIS platform, users will run into the following problems:
(A) Files are not able to be written, created, or rewritten on the C:\inetpub\wwwroot\ directory.
(B) PHP uploaded temporary file will not be able to be written and this results in file upload problem. For example, $_FILES["FileID"]["tmp_name"] will not be able to be written.
(C) PHP tmpfile() command will fail.
In order...
Subscribe to:
Posts (Atom)