Saturday, December 11, 2010

Drop "Right" Menu Simple Solution Using UL(Un-numbered List) + CSS

The previous drop down menu was not able to be converted to "drop-right" menu. This is used instead:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<style>
#menu {width: 100px; background: #eee;}
#menu ul {list-style: none; margin: 0; padding: 0;}
#menu li {position: relative;}
#menu ul ul {position: absolute; top: 0; left: 100%; width: 100%;}
#menu ul ul {display: none;}
#menu ul li:hover ul {display: block;}
.butlook {display: block; border-width: 1px; border-style: solid; border-color: #ddd; margin: 0; padding: 3px 3px; font-size: 12px; font-family: tahoma;}
</style>

<body>


<div id="menu">

<ul>
<li class="butlook">Menu 1
<ul>
<li class="butlook">Menu 1 Item 1
<li class="butlook">Menu 1 Item 2
</ul>
</li>
</ul>
<ul>
<li class="butlook">Menu 2
<ul>
<li class="butlook">Menu 2 Item A
<li class="butlook">Menu 2 Item B
</ul>
</li>
</ul>

</div>

</body>






Such method is important as it is widely used nowadays. It's heavily used in facebook if one hasn't noticed it yet. Although it is not exactly the same, but it is all about using the CSS with the <UL>. What's next? Flip left/right image like iphone trick? I have codes with me but I haven't compiled it up yet. Stay tuned?
Read More »

Wednesday, December 8, 2010

Drop Down Menu Simple Solution Using UL(Un-numbered List) + CSS

Here are the sample codes in HTML and CSS (important code shown in red): <style type="text/css"> #main_menu ul {padding: 0; position: absolute;} #main_menu li {float: left; position: relative; } #main_menu a {text-decoration: none;} .main_item {list-style: none; border: 1px solid black; background-color: #DDEEFF; text-decoration: none;} .item {list-style: none; border: 1px solid black; background-color: #FFEEDD; width: 100%; text-decoration: none; text-align: center;} #main_menu...
Read More »

Monday, December 6, 2010

ASP Sniffer Out IE Sample Codes

user_agent = request.servervariables("HTTP_USER_AGENT")if InStr(user_agent,"MSIE") > 0 then position = "absolute"else position = "fixed"end ifThese codes above is good to sniff out IE with the rest of the browser in A...
Read More »

DIV mask layer not fully covered on top when there is a scroll bar

It's common to create a "mask" layer on top of the page in order to display photos, pop-up messages, etc.I used to used the "absolute" positioning to do the job under I lately discovered the so called "masked" will move if there is a scroll bar (when shrinking the window's size).This problem can be easily solved by just setting the DIV to "fixed" position.Another problem solved! But wait a minute. This solution doesn't work in IE! Let me see if there is a workaround for this...After trying...
Read More »

Sunday, December 5, 2010

How to Print % (percentage sign/symbol) in ASP?

I've tried %%, it doesn't work.So after googling around still no result.After that I thought about printing special character using ASP and look up the ASII code table, I came out with this solution:MyString = "<td width=100" & chr(37) & ">"...print MyStringWalla! Problem solv...
Read More »

Wednesday, December 1, 2010

Server Error: HTTP Error 500.19 - Internal Server Error

It's been a while since my last posting. Busy, busy, busy!Anyway, while installing IIS to my notebook with Windows Vista, I got this Error 500.19. This problem did not pop up during my installation on a Windows 7 PC.Here's the solution:I just added a IIS_IUSRS user to the root folder of the IIS, everything is fixed!Before this, one needs to remember to turn of the Apache if you happen to run it and got a message of access problem to the directory of your web files.Good luck everyone and...
Read More »

Wednesday, March 17, 2010

Best Way to Round Up Numbers Using Javascript

I previously found several solutions to round up (float) numbers to closest two decimal places. Some are using complicated function with sofisticated codes but I find this one-liner quite effective and efficient:Math.round(num*100)/100; // for two decimal placesMath.round(num*1000)/1000; // for three decimal places..I appreciate the author who did this and sorry for forgetting where I get it fr...
Read More »

Tuesday, March 16, 2010

Firefox isn’t Foxy When it comes to Javascript Execution

Strangely, Firefox executes Javascripts the slowest compared to IE, Safari and Chrome. It is a strange phenomenon as it doesn’t affect IE, Safari or Chrome. There is also a claim that Firefox 3.5 or higher can run Javascript faster. Since there are still many who are using Firefox 3.0 or lower, I will stick to it unless 3.0 has been forced to phase off.No real fix can be found yet unless to upgrade to version 3.5 or higher which is not a good solution. I cannot just ask all the visitors...
Read More »

Monday, March 15, 2010

Onmouseover/Onmouseout Event Trap Trick

If you happen to need to do a mouse trap on certain link in HTML, you will use onmouseover and onmouseout to due with it. There is one way to save the onmouseout event trap to simplify the procedure. It is to define a fixed property to it such as the color of a table, the color of a border or even a background image. In that case, during a onmouseout event, the browser will go back to your original fixed settings. But if you purposely define how to due with it during a onmouseout event,...
Read More »

Sunday, March 14, 2010

Firefox Pointer Change Problem Using Javascript in <MAP>

If you are using <MAP> and you want to do a onmouseover event trap to change the mouse cursor to ‘pointer’, it won’t work in Firefox but still good for the rest, viz., IE, Chrome and Safari. I didn’t it on Opera though.Firefox requires at least a hyperlink anchor, viz., <a href=…> to change the cursor to pointer whenever the mouse it on top of the defined area.Good news is that this is the workaround. Bad news is that for firefox, you can only change it to ‘pointer’ type cursor...
Read More »

Saturday, March 13, 2010

MySQL Problem with Japanese/UTF-8 texts

If you have tried to put Japanese or UTF-8 texts in MySQL, chances are it will show “junky” characters after you save/reopen it. An adjustment is needed to fix this simple problem:Declare the data type as VarBinary. Problem solved.I’ve tried changing the character set to UTF-8, using the “mysql_enable_utf8=1” setting, making SQL query like “SET CHARACTER SET utf8_unicode_ci;”, nothing seems working. Anyway the simple solution above solved the problem. I have tried it with MySQL 5.x.Pitfall:...
Read More »

Friday, March 12, 2010

IE Text <INPUT> Minimum Width Problem

If you happen to specify the “size” in the text input form using <input> which is less than 10, chances are the size will be “fixed” to around 10 even if you specify a lower number. In order to solve this peculiar problem of IE or maybe Firefox or Chrome, I have tried the following CSS declaration and it works:table-layout: fixed;Strangely, only Safari works well without this fix. Firefox and Chrome can’t even work well using this fix. But at least IE doesn’t have this problem after...
Read More »

Thursday, March 11, 2010

Paypal Login Window Set to Other Languages (Japanese) by Default

I was requested by a Japanese customer to set the default login window in Japanese. I have tried setting the lc (locale) query string to “JP”, it just works half way with English and Japanese as the choices. But Japanese was treated as second language in the locale of “JP”. The default page is still English. Then I tried all the funny things and eventually this works out right:<input type=hidden name="locale.x" value="ja_JP">Now the default Paypal login page is in Japanese! But of...
Read More »

Wednesday, March 10, 2010

Fixing PERL script saved in UTF-8 Format using Notepad

If your PERL script needs to display non-English texts, say Japanese or Chinese, usually you will save your script in UTF-8 format. Problem arises if you are using Notepad to save the UTF-8 format as it adds the BOM (Byte Order Mark) header to the file.The problem is that PERL won’t run the UTF-8 file with BOM header once it is uploaded to the server. However, it will run fine if you are running with later version of Apache locally using your Windows based PC.To solve this problem (if...
Read More »

Tuesday, March 9, 2010

Redirect a URL inside a frame to a _top page

It’s easy to redirect a URL if you don’t care whether you are from inside a frame or to its own frame using META redirection or window.location javascript redirection.What if your HTML is inside a frame calling to redirect itself to a _top page? Tricky?I use this:if (document.referrer.indexOf('YourAliasName') != -1) {   top.location.href='http://www.YourMainDomainName.com';}You can substitute YourAliasName with a portion of your domain alias name so that the redirection...
Read More »

Monday, March 8, 2010

Use Javascipt to change the <select> Pre-select Item

I use this to change:document.getElementById('idname').selectedIndex = 0;Tested to work fine with latest IE, Firefox, Safari and Chrome. Your <select> also needs to address the id name such as: <select id=idname>You can change the selectedIndex to something else. 0 means the first selection, 1 means the second, e...
Read More »

Sunday, March 7, 2010

Assigning SetTimeout/SetInterval Functions with Argument(s)

If Javascipt’s SetTimeout()/SetInterval() is assigned with a function that contains argument, it won’t run. After trials and errors, here’s the way that works well with latest version of IE, Firefox, Safari and Chrome:setInterval(function(){function_name(argument)}, 1000);Noted those highlighted in red is a function to call another function. I have tried using eval(), it works well in Firefox but it won’t in IE. This trick is to make sure it works with all type of browsers. Using common...
Read More »

Saturday, March 6, 2010

Calling a Function in iframe

I mentioned how I call a function from iframe. Now I explain how I do the opposite, calling a function in iframe from the parent or main HTML.After trying a few suggestions found using Google, I find this working for all the browers I use, viz., IE, Firefox, Safari and Chrome:document.getElementById('framename').contentWindow.functioname(argument);You can replace your own framename, functionname and argument.Update: It will not work on Chrome if you are running in local host due to security...
Read More »

Friday, March 5, 2010

Paypal doesn’t like to be framed in IE

I tried to redirect a shopping cart form to an iframe a while ago but the Paypal keeps showing an Error something like "your last action could not be completed" while using IE but it works fine in Firefox, Safari and Chrome.Then I make the redirection to a brand new page by adding the "target = _top" to the link anchor and everything works fine now.Weird problem. Obviously Paypal doesn't like us to enclose it in a frame.September 2011 Update: Now Paypal doesn't allow its content to be...
Read More »

Thursday, March 4, 2010

Speeding up Firefox

I notice HTML content will be a bit slow to show up on Firefox whenever there is an error reported in Firefox Error Console.As a responsible web developer, it is our duty to run the Error Console every now and then. Just clear the history and have a run of Error Console and reload of target website, all the problems with the Firefox will show up. Fixing some problems in Firefox platform could fix the speed problem in other browsers as well. So start screening with Firefox’s Error Console...
Read More »

Wednesday, March 3, 2010

Firefox is responding slow on Javascript’s onresize()

Compared to IE, Safari and Chrome, Firefox is the slowest in response to the onresize usually put in the <body> tag.I was testing this using the latest Firefox version and am not sure how the older versions did. I make my HTML to call a function to relocate an object whenever there is a resize event on the browser’s window. Something interesting for developers to pay attention to. If your onresize() is responding slowly to resize events, chances are you are using Firefox 3 and above....
Read More »

Tuesday, March 2, 2010

Diplaying Server Date Using PERL and Javascript

I only find PHP solution after googling around, but I wanted to use PERL. Here’s how I did it:PERL side:#!/usr/bin/perl$time = localtime(time);print "Content-type: text/html\n\n";print "var serverdate='$time';"; exit; Javascript side:<script language="JavaScript" src="/cgi-bin/getservertime"></script><script type="text/javascript"><!--document.getElementById('time').innerHTML = '<font face=tahoma size=1>'+serverdate+'</font>'; //--></script>Please...
Read More »

Monday, March 1, 2010

Get the same Browser’s width value across all Browser types

Firefox, Safari and Chrome have almost the same way to measure the page width of the browser window except IE.This is due to the fact that IE is using different way to get the width of the window than Firefox/Safari/Chrome.IE uses “window.innerWidth” property whereas Firefox/Safari/Chrome uses “document.documentElement.clientWidth” to get the width of the browser.The problem now is that IE tends to include the width of the scrollbar where around 15-18 pixels are added to the sum.I use...
Read More »

Sunday, February 28, 2010

Valign doesn’t work in iframe

<iframe> vertical alignment doesn’t work with normal valign property declaration. It has to be adjusted using CSS. Here’s the CSS codes:iframe { vertical-alignment: top; }By default if this is set, it aligned to the middle vertical...
Read More »

Saturday, February 27, 2010

Sending Email using PERL Net::SMTP module

I recently bumped into a problem with my old CGI script that sends emails from LINUX/UNIX server in PERL platform.I later found out that the server I rented/shared is no longer supporting emails using the sendmail –t command. I found a solution to it by using the PERL module of Net::SMTP.Here are the codes that saved my day:use Net::SMTP; $smtp = Net::SMTP->new("smtp.yourdomain.com"); $smtp->mail("username\@ yourdomain.com"); $smtp->to($touser); $smtp->data(); $smtp->datasend("MIME-Version:...
Read More »

Friday, February 26, 2010

My Lazy Confession

I like to use shortkey, especially the address bar shortcut.I like to use CTRL-ENTER whenever I type the web address.For example in the address bar,I type yahoo followed by CTRL-ENTER. The browser will complete it as http://www.yahoo.com and go to this address. Whether it is IE, Safari, Firefox or Chrome, it is able to perform this trick.Lazy me, lazy me... Update (April 5th, 2016): Most browsers can now "auto-complete" your website address if you type in the domain name of popular...
Read More »

Thursday, February 25, 2010

Javascript to hide/unhide table layer for IE+Firefox+Safari

HTML (Div Layer):<div id="myDiv" style="position:absolute; visibility:hidden; width=100%;"><table ......</table></div>HTML (Event Starter):<input type=checkbox name=mycheckboxid onclick="javascript:toggle(document.myform);">Javascript:function getObj(name){  if (document.getElementById) {   this.obj = document.getElementById(name);   this.style = document.getElementById(name).style;  }  else if (document.all)...
Read More »

Wednesday, February 24, 2010

PERL connect to DBI subroutines (smart detect)

Here are the codes:sub connect_db { if (!$connect) {  $dbh = DBI->connect("dbi:mysql:your_db_name;host=localhost:3306;user=db_user;password=user_password") or die "Couldn't connect to database: DBI::errstr\n";  $connect = 1; }}sub disconnect_db { $dbh->disconnect; $connect = 0;}Try to use as little disconnect as possible as connecting and disconnecting may cause delay and to the HTML connection. As you may already know you may need to install...
Read More »

Tuesday, February 23, 2010

Installing PERL CRYPT:SSLEAY module

This module is important for SSL - LWP connections. I used this command to install the module using ppm (usually in c:\Perl\bin):ppm> install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppdI just reran the command a few days ago and it is still worki...
Read More »

Monday, February 22, 2010

How do you scroll to the top within iframe?

I have tried:parent.scroll(0,0);window.scroll(0,0);...Finally I found a site that says:window.parent.scroll(0,0);That saved my day! Hope it works for you t...
Read More »

Sunday, February 21, 2010

How to dynamically display the content of your Cookie using Javascript?

Almost the same as the previous post. Just need to replace the cookie variable in the assignment of innerHTML.HTML:<span id="myHTML"></span>Javacript:document.getElementById('myHTML').innerHTML = document.cookie.indexOf("myCookieName");   // where 'myCookieName' is the name of the cookie such as the shopping cart item quantity, etc..You can set up a Javascript function to handle this dynamic capability and receive event calls from omouseover, onload, ... HTML event...
Read More »

Saturday, February 20, 2010

How to dynamically change the content of your HTML using Javascript?

HTML:<span id="myHTML"></span>Javascript:document.getElementById('myHTML').innerHTML = htm;   // where 'htm' is a variable to hold the HTML codes you want to display in the <span> portion.You can set up a Javascript function to handle this dynamic capability and receive event calls from omouseover, onload, ... HTML event as a trigger to the change of content. You can also set up a timer to change the content periodical...
Read More »

Friday, February 19, 2010

Which Broswer is the Best?

It depends on whether you want to use it to surf or you want use it to develop websites.For web developers, it is always Firefox as it comes with tools to help troubleshoot websites and the plug-ins are widely available such as plug-ins to view raw HTTP headers, etc.If you want to use it to surf net, I would recommend Safari and Chrome. I use to like Safari. After installing Chrome, Google has the...
Read More »

Thursday, February 18, 2010

Who says CGI/PERL is obsolete?

Some say CGI/PERL is slow.Some say CGI/PERL has security problem.Some say CGI/PERL is phased out by PHP....But there is still one "BIG" website that is still using CGI/PERL until today. Have you seen this:https://www.paypal.com/my/cgi-bin/webscrIf CGI/PERL is not good, why is PayPal still using it until today to deal with large sum of credit everyday? UPDATE (April 4th, 2016): It has been six years since I posted this comment about PERL's popularity. But I now would say PERL is already...
Read More »

Wednesday, February 17, 2010

Google Chrome Review

I have decided to add Google Chrome browser to my browser list as test vehicle of websites I built or am going to build.The download path is http://www.google.com/chrome/After clicking the download button, a terms-and-conditions page appeared asking downloader to "agree and download".The download file is called ChromeSetup.exe and it is just 551KB. Very small. It takes around a second to download...
Read More »

Tuesday, February 16, 2010

Speeding Up PERL in CGI Output

Usually I will do the following setting:select(STDOUT);$| = 1;print "Content-type: text/html\n\n"; # whenever your browser sees this, it will blank the screen$| = 0;$| = 1; is to make sure to send data to client web browser immediately. It is like a "live" connection.$| = 0; is to make sure to send data to client web browser only when the buffer is filled.Such configuration can make the user feel that the response of the web is fast but it is actually just slightly faster.If you use...
Read More »

Monday, February 15, 2010

PERL Trick to Make Alternative Row Color

The mod or modular operator in PERL (%) is responsible for this trick.The following codes show how I did it:... $total_hits++; if ($total_hits % 2) { $rowcolor = " bgcolor=#FFEEEE"; } else { $rowcolor = " bgcolor=#FFFFFF"; }...These codes are in a loop to list out all the items. You can place the $rowcolor in the <TR> tag. The rows displayed will be in pink and white alternative...
Read More »

Sunday, February 14, 2010

The Maximum Length of a Cookie Name

I once encountered a problem with the cookie length with Firefox when the cookie name or value is too long.I now try to imitate the same problem I encountered last time, the problem is gone.But I use shorter cookie name and value so that Firefox won't reject them I encountered last time which caused me a lots of pain debugging.It's good to test cookies using firefox as one can view the cookies easily using this:Tools->Options...->Privacy->Show CookiesThank goodness there is a...
Read More »

Saturday, February 13, 2010

PERL codes to check whether a image file Exists

Here are the codes I have been using. The key is to use the "-e" in the if statement. Other than that it is not a hard programming problem: if (-e "../htdocs/prod/small/$image_id.jpg") { $img_path = "/prod/small/$image_id.jpg"; } else { $img_path = "/img/default_small.gif"; }Those in red (the relative path to the cgi-bin directory) depend on your server's configuration. One needs to ftp into the server to see the structure.You can also "elsif" to support more file format rather than...
Read More »

Friday, February 12, 2010

The FTP software I like best

I like Filezilla. Especially the "File permissions..." feature, one can easily set the file permission without having to worry much about. You can even set permission for many files at the same time. Anyway, this only applies to Linux/Unix based servers. For Windows based servers, the file permission has to be set in the control panel.I have used many other FTP softwares before. Nothing compares to...
Read More »

Thursday, February 11, 2010

How to highlight the entire <TR> during mouseover?

For IE, this doctype or similar one is needed:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">If you use onmouseover+onmouseout to change the style using the method I mentioned before could be painful.I came across a method which is code saving:- use TR:hover.First I have this CSS declared:tr.rowname:hover { background-color: #FF8888; color: #FFF; }And I used it in HTML:<tr bgcolor=#FFF1F1 class=rowname><td>blah blah blah</td></tr>This...
Read More »

Wednesday, February 10, 2010

IE Bug#1

If you have a DIV and you don't specify the width, the DIV won't show up ever until you specify the width.I have tried the same thing on Firefox and Safari, they are both able to show the DIV without having to specify the width of the D...
Read More »

Tuesday, February 9, 2010

Randomize Image Display using PERL

From HTML side:<img src="/cgi-bin/myimage">From PERL side (myimage):#!/usr/local/bin/perlprint "Content-type: image/gif\n\n";$pic[0] = "image0.gif";$pic[1] = "image1.gif";$pic[2] = "image2.gif";$rndm = int(rand()*3);open(PIC, "./../image/$pic[$rndm]");binmode(PIC);binmode(STDOUT);while (<PIC>) { print $_;}close(PIC);This is neat. Seldom a programmer reveals this simple but neat secr...
Read More »

Monday, February 8, 2010

Randomize Image Display using Javascript

When you reach the location of your HTML that you need to display an randomized image, you can use these codes as a reference:<script language="javascript"><!--var rn = "";rn = Math.floor(Math.random()*11);if (rn == "0") {document.write("<img src=\"/img/pic0.jpg\">");}if (rn == "1") {document.write("<img src=\"/img/pic1.jpg\">");}if (rn == "2") {document.write("<img src=\"/img/pic2.jpg\">");}if (rn == "3") {document.write("<img src=\"/img/pic3.jpg\">");}if...
Read More »

Sunday, February 7, 2010

Set Cookie with Variable Using Eval in Javascript

Have you ever encountered a situation that you need to set a cookie with a javascript variable added to a cookie? But you cannot use "+" in your cookie assignment?Here is where the javascript eval() comes into play:function assignfruit(type) { eval('document.cookie = "fruit='+ type +';"');}Since you cannot do this: document.cookie = "fruit="+ type +";" or this: document.cookie = 'fruit='+ type +';', you need to use eval().Something I found out and I think it is useful to beginners to...
Read More »

Saturday, February 6, 2010

How to process Selection/Radio/Checkbox data using Javascript?

This corresponds with the previous post:For Pull-Down Selection:document.docname.variablename.selectedIndex// Replace docname with your document name and variablename with your selection variable name such as country. The selectedIndex starts from 0 which is the first item in your pull down selection list.For Radio Selection:document.docname.variablename[index].checked// If selected, this notation will become 1. The index starts from 0. If your radio selections have two items, the first...
Read More »

Friday, February 5, 2010

How to process Selection/Radio/Checkbox data in PERL?

This corresponds with the previous post:For Pull-Down Selection:if ($form_data{'country'} eq "Australia") {...}For Radio Selection:if ($form_data{'type'} eq "orange") {...}For Checkbox Selection:if ($form_data{'type'} eq "on") {...}Please check with the previous posts for the the input/selection HTML. Please also note that you need to have the legendary cgi-lib.pl library called before you can use $form_data{'---'} hash table that captures the query strings from your HTML document.P.S.:...
Read More »

Thursday, February 4, 2010

All the Pre-selections and Pre-checks in HTML Selection ie. OPTION and INPUT(Radio+Checkbox)

For Pull-Down Selection:<select name=country><option>Argentina</option><option selected>Australia</option><option>Austria</option><option>Bahamas</option>...</select>For Radio Selection:Orange <input type=radio name=type value=apple checked> Apple <input type=radio name=type value=orange>For Checkbox Selection:<input type=checkbox name=type checked>Coming next, how to detect those selections in PERL-CGI scri...
Read More »

Wednesday, February 3, 2010

Weird Image Alignment Problem in HTML

Ever encounter this problem?The alignment of your image and the adjacent text seem hard to be aligned. The text is always lower than the lowest part of the image. No matter how you adjust the CSS of the <img>, nothing works.There is a simple solution to this:<Table><TR><TD><img src="/image/but1.gif"></TD><TD><a href="[http_address]">Click if you need...
Read More »

Tuesday, February 2, 2010

How to fix HTML table problem?

This is the most common problem that a web developer faces throughout his or her career. It is the table problem. Why is the text not aligned? Why is the image glued to the other end instead being centered? These are the common questions in mind especially when you have many layers of tables stacked up to each other.There is a easy fix to this. COLOR IT!But RULE#1 before this. Make a backup copy. When you have a copy backed up, you dare to do any experiment with it. Usually I will purposely...
Read More »

Monday, February 1, 2010

How to perform double underline in HTML?

It is just a trick I learned recently to double underline the grand total in a shopping cart.Actually there is no direct solution to this.The trick is to combine both conventional <u> and CSS to perform the trick.Here are the codes:<table><tr><td style="border-bottom: 1px double #000;"><u>underline this</u><td><tr></table>Yes, the double needs to be there and so is <u>. Make sure your <td> is as narrow as possible or the...
Read More »

Sunday, January 31, 2010

How to mix two DOCTYPE in one website?

Simple, just make one of them in <IFRAME>. For example, you need these two types in one web page:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">AND<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">Which one to be in IFRAME and which one to be in main frame?It is recommended to make the one with looser requirement in the main frame. I would pick the HTML 4.01 one in my main frame. How...
Read More »

Saturday, January 30, 2010

How do you remove/force the underline in link anchor <A>?

To remove:Use CSS. Simply use the following CSS codes:a {text-decoration:none;}or directly:<a href="[link destination]" style="text-decoration:none;">link</a>To force:<a href="[link destination]" style="text-decoration:underline;">link</a>or<a href="[link destination]"><u>link</u></a>To show underline only if the mouse is over the top:CSS method:a {text-decoration:none;}a:hover {text-decoration:underline;}Hope you like these simple ones....
Read More »

Friday, January 29, 2010

How do you highlight a table data (<TD>) without using fancy javascript routine?

There are many sites in the world that are using fancy javascript functions or subroutines to deal with the dynamic CSS.But what if we only need to control a small part of our website? Can we use a quick and dirty method without having to mess with function calls to and fro javascript engine?Here is a simple way to do it. Put these in your <TD>:<TABLE><TR><TD width=100 onmouseover="this.style.background='#ffdddd';this.style.cursor='pointer';" onmouseout="this.style.background='#ffeeee';"...
Read More »

Thursday, January 28, 2010

How to assign quotation mark in a javascript variable?

For example if you want to put "'"(single quotation mark) into a javascript string variable:var str = '<tr><td onclick="change('variable')"><img src=apple.jpg border=0></td></tr>';where variable needs to be replaced with a variable. But variable needs to fit into the string value assignment, this needs to be done:var str = '<tr><td onclick="change('+variable+')"><img src=apple.jpg border=0></td></tr>';But the single quotation...
Read More »

Wednesday, January 27, 2010

Fastest Way to Get The Coordinates For Usemap

As we all know that we need to specify the coordinates when we set up the Usemap for our image.I recommend using Photoshop.Launch Photoshop (I still use version 7 in 2010), pull down Edit->Preferences->Units & Rulers. Set the rulers setting to pixels.Open your image file. The use the selection tool to select the upper left corner like in the following:Then go to the navigator toolbar window...
Read More »

Tuesday, January 26, 2010

Dynamic IFRAME Height Adjustment

Before going any further, this feature will NOT work with the following DOCTYPE:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">Here we go:You just need this to be called:document.getElementById('myframe').height=500;This will change the height of iframe named 'myframe' to 500.You can also call within the iframe:parent.document.getElementById('myframe').height=500; Isn't daddy gre...
Read More »

Monday, January 25, 2010

Point your finger?

There are many web sites that I encountered with this finger problem.The table row is converted to change color during a "mouseover" event.But the mouse cursor will only turn to a hand sign if it hovers over the link. If your mouse pointer moves away from the <a> link, you will see this:For those who are used to Windows or Mac environment will not be happy about this. In order to make it more...
Read More »

Sunday, January 24, 2010

How do you control the height of a table?

For those who tried to adjust the definite height of a table know that it is hard to control the height of a table that looks similar in all the browsers.Here are the codes that I used to make sure the height is showed as defined:<table cellpadding=0 cellspacing=0 border=0><tr><td height=13><img src="img/dummy.gif" height=13 width=1></td></tr></table>You also need to prepare a dummy gif file to make this happen. The dummy gif file is better to...
Read More »

Saturday, January 23, 2010

How does your index.html capture the HTTP_REFERER?

By sending the "REFERRER" variable to cookie:<script language="Javascript"><!--if (document.cookie.indexOf("url") == -1) { document.cookie = "url=" + escape(document.referrer) + ";path=/";}//--></script>The "document.referrer" contains the referrer's URL for any pages at all time. All you have to do is to send the content to the cookie. The cookie will record the first referrer data so that it will capture the source of the link to your website. The (document.cookie.indexOf("url")...
Read More »

Friday, January 22, 2010

Direct Download Link with PERL - CGI

There are times that you need to make sure you record or filter before your visitors download your files. Here are codes if you are running CGI using PERL:open(FILE, "../file/$fn"); #file is the directory and $fn is the filename@file=<FILE>;close(FILE);print "Content-Type:application/x-download\n"; print "Content-Disposition:attachment;filename=$fn\n\n";print @file;Note that you don't need to print the html header :"Content-type: text/html\n\n" before this. You can also add the Content-Length...
Read More »

Thursday, January 21, 2010

Big IE Bug -> Background

Have you ever encountered a problem putting a background image in a table row or <TR> and it doesn't show up in IE?Yes, of course. IE doesn't support background image in <TR>. Put the background image in <TD> instead. Or wrap another table around the row and put the background in <TD> above it.But background image support in <TR> works well in Firefox and Safari.There are more problems with IE. I will dig up more in the futu...
Read More »

Wednesday, January 20, 2010

PHP vs CGI - PERL vs ASP

What a strange round-up comparison.I like CGI - PERL combination because Linux server is free to set up if I want to build my own web server. PERL is much powerful than ASP after comparing both programming platform. Many tasks can be completed with minimum amount of codes compared to ASP. Anyway, ASP is obsolete and ASP.NET is just as versatile as PERL programming environment.I like PHP as it is like the combo of PERL and ASP. It has the server side thing as well as the PERL programming...
Read More »

Tuesday, January 19, 2010

What is the best resolution for Web?

This is the first thing to ask yourself during the design stage.You create a new photoshop document and you are asked about the size in pixel.800x600, 1024x768, 1280x1024, 1280x720, 1366x768, 1600x1200, 1920x1080, 1920x1200?I always start with 1024x768 as my beginning resolution to design with.Actually, my maximum width is just 1000 instead of 1024. The scroll bar on the right side of the browser takes up some space too. As more and more monitors are going toward 1920x1080, I may start...
Read More »

Monday, January 18, 2010

The Web Editing Platform

Should I use Frontpage, Dreamweaver or Notepad to convert my design to HTML format?The answer is "it is all up to you".The cheapest way is to use Notepad or any free text editing software.For me, I only Notepad. If you are too comfortable with Frontpage or Dreamweaver, when it comes to writing HTML codes in CGI, PHP or ASP(x), you might have a problem.If you plan to make web development as your lifetime career, why don't you pick some HTML knowledge as web is all about HTML (may change...
Read More »

Sunday, January 17, 2010

Web Trick #4: Should Load Fast

This could be the most technical part of all four parts. I like this part as I am from technical background.I like use the word “webify” myself as this is the process of converting your photoshop design to HTML file(s).The explanation of this section can be very extensive but for the sake of clariness, I go for the blog style, the simplified version.Basically in order for a web site to load fast, the number of image file and their file size must be kept to the minimum.For example, you...
Read More »

Saturday, January 16, 2010

Web Trick #3: Meaningful Content

Make your point straightforward.It is better to make one main point than many points in a single page.Visitors are human. They can only focus on one thing at a time.Beside the look and feel of your website, your content is the key of the development. It gives meaning to the website or it just becomes rubbish.There is one trick that works on almost every occasion. Choose a photo or picture that summarizes the whole story. For example, if you page is about selling a house, show the photo....
Read More »

Friday, January 15, 2010

Web Trick #2: Easy to Navigate

This is a tricky part.Most web developers know this is important. But when it comes to implementation, it is quite a task.This also depends quite a lot on the design as well. Layout of the website is properly planned with similar links or buttons grouped at the same place. Visitors will have a much easier time to recognize the location to browse, look for information, inquire or quit and back out.My advise is to put more effort on the design to make use of color to group links of similar...
Read More »

Thursday, January 14, 2010

Web Trick #1: Good First Impression Feel

How do we go about starting to develop a website?For me, I started with a Photoshop stage. I used to draw it on a piece of paper. But I now go straight to Photoshop.Before drawing on the photoshop, I will ask customers for references if he or she has any website that is worth referring to.Now I will make a few Photoshop samples and see if I like it or not. I will spend time looking at other websites and then look at mine. I take first impression very seriously. I only give myself 2-5 seconds...
Read More »

Wednesday, January 13, 2010

What is considered a good website?

Here is a personal point of view:1) Good First Impression Feel2) Easy to Navigate3) Meaningful Content4) Should Load FastThese GEMS will be explained one by one in the following days!!!Good d...
Read More »

Tuesday, January 12, 2010

PERL TCP Socket Codes with LWP (HTTPS/SSL, POST method)

Planned to delay this but what the hack, just let the series continues.For such connection, LWP is needed:use LWP::UserAgent; #call up the LWP modulemy $ua = LWP::UserAgent->new;$req = new HTTP::Request POST => "https://www.yourSSLURL.com/script?var=variable";$req->header('Accept' => 'text/html');$req->content_type('application/x-www-form-urlencoded');$req->content("a=a&b=c&c=c");$res = $ua->request($req);#to transfer $res->as_string to @HTML arrayopen...
Read More »

Monday, January 11, 2010

PERL TCP Socket Codes without relying on LWP (Part 2: POST method)

As promised, here are the codes:replace (GET method):print S "GET /Login.aspx?a=apple&cat=main HTTP/1.1\nHost:www.theSiteDomainName.com\n\n";with (POST method):print S "POST /Login.aspx HTTP/1.1\nHost:www.theSiteDomainName.com\nContent-Length: 16\n\na=apple&cat=main"Note that you don't need to put the query string in the URI. Instead you need to post the query string as output data. You also need to specify the length of your data. This is a tricky part. The easiest way is to put...
Read More »

Sunday, January 10, 2010

PERL TCP Socket Codes without relying on LWP

I don't quite like to use the modules in PERL as I am always paranoid about its absence in certain hosting companies.Here are the codes to make a TCP connection and send and receive a HTTP GET query without the LWP module:use Socket;my $peer = sockaddr_in(80,inet_aton("www.theSiteDomainName.com"));socket(S, PF_INET, SOCK_STREAM, getprotobyname("tcp"));connect(S, $peer) or die "Couldn’t connect!";print S "GET / HTTP/1.1\nHost:www.theSiteDomainName.com\n\n"; # Make a GET query to root...
Read More »

Saturday, January 9, 2010

Javascript with IE is painful

Most web developers know this is a painful combo: JS + IE = Pain.Whenever a developer sees this on the lower left corner of the browser window:he or she will be more likely sad. Double clicking on it will pop up a window telling you the javascript error that doesn't make sense (after clicking show details to show the error).There is one time I encounter errors that are not consistent on every run....
Read More »

Friday, January 8, 2010

Transparent Flash

I once have this requirement to be fulfilled to make a swf file to appear transparent on a web page. After "googling" around, I found that:<PARAM NAME=wmode VALUE="transparent">has to be in the OBJECT tag for IEandWMODE="transparent"has to be in the <embed> tag for Firefox.and the background color of EMBED and OBJECT will be treated as transparent color as in the swf file.Surprisingly, the result looks pretty good in Firefox. But the IE looks terrible. The edge of object in...
Read More »

Thursday, January 7, 2010

JPEG or GIF?

This could be the biggest question in beginners' mind when it comes to developing a website. My answer is "whichever one gives you a smaller file size with the least distortion".The best way is to use Adobe Photoshop "Save for Web" feature (version 7 or above).In that feature, you'll see how different output format gives you different file size. Adjusting the number of color (GIF) or changing the compression ratio (JPEG) can also affect the file size.If the image is of photo nature, such...
Read More »

Wednesday, January 6, 2010

Putting HTML tag in Blogspot

There's something that I learned a few days ago:How to Put HTML tag in Blogspot?I kept getting error from the Posting editor saying that the HTML tag is not allowed. Then I realized in order to put HTML tag inside a HTML editor, it has to be "unescaped" before they can be embedded inside a HTML-based editor.Then I googled around and I found this:http://www.reconn.us/component/option,com_wrapper/Itemid,62/Actually I needed to "escape" those characters instead of "unescaping" them.After...
Read More »

Tuesday, January 5, 2010

Calling Daddy?

Start to scratch my head what to write today. I thought I was more affluent than this. Anyway, this is a simple trick to call a javascript function from an iframe:"javascript:parent.myfunction()"This is useful when you are using iframe and you need to call a function that is running on your main HTML or the "daddy" HTML. I call the iframe the "child".Why do you need to call "Daddy" and not run javascript directly from iframe?If you need to control a DIV layer from an iframe, you need this....
Read More »

Monday, January 4, 2010

The CSS Padding Problem

There is one time when I was using the following CSS to style my table:padding: 10px;It wasn't showing any padding no matter how I fix it. I later found out it is a HTML version problem.After adding this, the problem is fixed:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">This is a short posting. Hope you don't mi...
Read More »

Sunday, January 3, 2010

iFrame or not to Frame?

Once a web developer touches iframe, it's hard not to in the future.Web developers can get addicted to iframe as it is a versatile feature.One can easily create an iframe using this syntax:<iframe src="test.asp" width=100 height=100 scrolling=auto frameborder=0 align=right id="iframe1"></iframe>This creates an iframe of 100x100 in size that calls to main.asp. The 100x100 area is reserved for this test.asp.The purpose of iframe is to separate the loading of various HTML files....
Read More »

Saturday, January 2, 2010

More tricks?

This is just my second trick and I would like make it quick. Trying to discipline myself to record all the tricks and tweaks that I have been using for the past ten years.Here's something that I always wonder, wonder how people make so much dynamics stuff using javascript which in fact looks like something running from the server.I must have been indulging in the world of Linux web programming environment using PERL and PHP. I realize if I put a default.asp in a Windows Web Server root...
Read More »

Friday, January 1, 2010

My First Web Trick

Today is 1st of January 2010. Happy 2010! I just realized that today is a good day to start a new project: blogging.Hi! I’m a semi-professional web programmer and would like to share web development tricks with new developers.This is my first blog this web trick thing:How to make all browsers to show a transparent layer?Div.abc {filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;}These are CSS codes for DIV layer with class name of “abc” using class=”abc” notation.With Comment:filter:alpha(opacity=80);...
Read More »