This code is used to fix formatting differences between browsers, due to different ways that browsers implement the W3C Standards. In the this example, if the visitor is using Internet Explorer, the page will display two line breaks. For any other browser (e.g., Firefox, Netscape, etc), the page will display one line break.
Javascript - Cookie Redirection to your home/disclaimer page
This code forces a user to enter your website through the home/disclaimer page. If a user bookmarks any other page on your website, this script will redirect them to the home/disclaimer page, when they initially enter your website. Once the cookie is set by the home/disclaimer page, the user may navigate to any page on your website.
This can be used to make sure that users see the content on your home/disclaimer page first. This may be useful when advertising items on your home page, or want your users to read any disclaimer statements before entering your website. The nice thing about this short piece of code, is that since most search engine bots/spider ignore javascript, the search engine bot will ignore the redirect code and crawl your content pages as if there is NO javacript redirection code on the page.
A cookie is set by your home/disclaimer page, and each content page checks to see that this cookie has been set. If a content page cannot find the cookie on the visitor's browser, it redirects them to the home page/disclaimer page, so that they can verify that they viewed the contents of the home page/disclaimer page. Once the visitor clicks the button on the home/disclaimer page, the cookie is set, and the visitor is allowed to navigate the content pages of your web site.
Step 1: Place this script on your home/disclaimer page; in this example, the name of the page is index.htm in the root directory.
Step 2: Place the following script on all of your sub-pages, that you want protected.
Method 1:
Place this piece of javascript between the <head/> and </head/> html tags on each web page you want protected.
Method 2:
You may also download the "readcookie.js" file here, copy the file to your directory, and add the following Server Side Include (SSI) statement between the <head/> and </head/> html tags on each web page you want protected.
PHP - Programmatically Disable ALL PHP Notices, Warnings, and Errors on a PHP Web Page
PHP - Programmatically Disable ONLY PHP Notices on a PHP Web Page
PHP - Programmatically Enable PHP Notices, Warnings, and Errors on a PHP Web Page
PHP - Programmatically Enable PHP Notice, Warning, and Error Logging for a PHP Web Page
Javascript - HTML body tag onload redirect
Javascript - HTML SELECT Tag, drop-down menu auto redirect
<select name="Fasteners" onchange="window.location.href=this.form.Fasteners.options[this.form.Fasteners.selectedIndex].value">
<option SELECTED value="">Quick Links</option>
<option value="./HHCS/">Hex Head Cap Screws</option>
<option value="./hexheadbolts/">Hex Head Bolts</option>
<option value="./carriagebbolts/">Carriage Bolts</option>
</select>
DEMO:
Javascript - Onclick event to open a page in the same window or tab
<button class="button4" onclick="window.location='Resume.pdf'">Download my resume<br>in PDF format
Example:
Javascript - Onclick event to open a page in a new window or tab
<button class="button4" onclick="window.open('Resume.pdf')">Download my resume<br>in PDF format
Example:
Javascript - Screen Resolution Detection Code
This code is used to determine the user's screen resolution. This is useful to display higher resolution images to users who have set their screen to a higher resolution. In the this example, if the visitor's screen resolution width is 1280 pixels or less, the browser will display a lower resoulution photo. If the visitor's screen resolution width is greater than 1280, the browser will display a higher resolution photo.
ColdFusion - Handle a NULL value with the cfif tag
ColdFusion converts all NULLS to empty strings. To test for a NULL with the cfif tag, use the following code example. This example sets a variable to 0, if the original value of the variable was NULL.
PHP - Display query output in two columns
<?php
$sSQL2 = "SELECT * FROM products WHERE pSection = $rs1[sectionID] ORDER BY pDescription";
$result2 = mysql_query($sSQL2);
PRINT '<table width=100%><tr bgcolor="#000000" height="24">'; $tds = 2; // number of columns
$count = 0; // result count
while ($rs2 = mysql_fetch_array($result2))
{
$prodcode = '';
$prodcode = $rs2[pID]; $count++;
PRINT '<td align="center" valign="middle">';
PRINT '<div id="2column"><a href="proddetail.php?prod=' . $prodcode . '">' . $rs2[pName] . '</a></div>' ;
PRINT '</td>'; // Check to see if it is a new row; if it is, then:
if (substr(($count/$tds), 2) == false)
{
// Create a new row
PRINT '</tr><tr>';
}
}
PRINT '</tr></table>';