Thursday, December 03, 2009

Bing Search Engine Error



But I do want this web page - the home page of bing. Refreshing didn't help either!

Tuesday, September 19, 2006

Javascript - Detecting the enter key being pressed

I had to develop a solution where the user could press enter or return from an input field and the correct submit button would be clicked. We could only use one form for the whole page.

This can be added to an external js file.

//In the onFocus event of the form input text element call the function
setSubmitBtn with the following parameters setSubmitBtn(form id, button id) e.g.
onfocus="setSubmitBtn('frmHitList', 'btnSave')"

//Global variable for the submit button set.
//Used by functions setSubmitBtn and keyPressed.
var submitBtnSet = null;
var btnFormId = null;

//Checks if the key pressed is the enter/return key
//If it is then click the button set by setSubmitBtn event
function keyPressed (Event) {
if (!Event)
Event = window.event;
var keyCodePressed = Event.keyCode;
if (keyCodePressed == 13) {
if (submitBtnSet != null) {
document.forms[btnFormId].elements[submitBtnSet].click();
submitBtnSet = null;
btnFormId = null;
return false;
}
}
}

//Set the submit button name which should be clicked when the user
//presses the enter or return key
function setSubmitBtn(formId, submitBtn) {
btnFormId = formId;
submitBtnSet = submitBtn;
}

//Calls the keyPressed function with every key pressed
document.onkeypress = keyPressed;

Saturday, March 04, 2006

Spyware and Malware

A friend had a problem with his computer running slow, crashing a lot, not booting up properly and many other abnormal things.

After a bit of looking around I discovered he had a lot of Malware and Spyware including a couple of Rootkits.

I used the Rootkitrevealer from System Internals to search for the hidden rootkits. I used Spybot from R & D to clean up a lot of the spyware and malware. I then used RegCleaner to clean up the registry.

The main guilty files I found were:
c:\WINNT\system32\drivers\fipmkchw.sys
c:\WINNT\system32\wsnxress.exe
c:\Programme\Vircanon (The folder contained a number of dodgy files - according to different anti-spyware companies - and a subfolder with logs)

They were all invisible to both Windows Explorer and MS-DOS. I removed the hard drive and added as a slave to another computer. The offending files were now visible.

I used the Autorun program from System Internals to find the registry key used at the startup.

The computer now boots up 1 minute 35 seconds faster.

Monday, January 31, 2005

Excellent Shortcuts for Eclipse

I found this pdf which lists shortcuts for Eclipse - http://eclipse-tools.sourceforge.net/shortcuts.html

I have found a number of them very useful.

Thursday, December 02, 2004

Maximum characters in a textarea

This is one close to one I developed myself but I can't find it anymore.

<!-- TWO STEPS TO INSTALL LIMIT TEXTAREA:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->
<!-- Dynamic 'fix' by: Nannette Thacker -->
<!-- Web Site: http://www.shiningstar.net -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
countfield.value = maxlimit - field.value.length;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<!-- textCounter() parameters are: text field, the count field, max length -->
<center>
<form name=myform action="YOUR-SCRIPT.CGI">
<font size="1" face="arial, helvetica, sans-serif"> ( You may enter up to 125 characters. )<br>
<textarea name=message wrap=physical cols=28 rows=4 onKeyDown="textCounter(this.form.message,this.form.remLen,125);" onKeyUp="textCounter(this.form.message,this.form.remLen,125);"></textarea>
<br>
<input readonly type=text name=remLen size=3 maxlength=3 value="125"> characters left</font>
</form>
</center>
<p><center>
<font face="arial, helvetica" SIZE="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.37 KB -->

Javascript - set focus on an element but after three letters

<SCRIPT LANGUAGE=JavaScript>
function focusOnField(sField)
{

// Returns the element whose ID is specified.
var tr=document.getElementById(sField).createTextRange();
tr.moveStart('character',3);
tr.select();
// document.getElementById("elementName").focus();
}
// Ende -->
</script>
<input name="elementNamelogin" value="ABC" size="8" maxlength="8" onkeyup="focusOnField(this.form,this);">

Calculate the number of characters in a textarea

Calculate the number of characters in a textarea

<script LANGUAGE="JavaScript">
//onClick event - place in the submit button tag - onclick="return textCounter('element', 'Description', 2000);"

function textCounter(field, fieldname, maxlimit){
var numCharacters = eval('document.frm_daten.'+field+'.value.length');
if (numCharacters > maxlimit) { // if too long
var extraCharacters = numCharacters - maxlimit;
var msg = 'You have entered ' + extraCharacters + ' extra characters in the ' +
fieldname + '. The maximum is ' + maxlimit;
alert(msg);
return false;
}
}
//onChange event place in the textarea tags - onchange="return maxLength('htmlPageTopContainer_frm_daten_inTxtAr_description', 'Description', 2000);"

function maxLength(field, fieldlabel, maxlimit){
var numCharacters = eval('document.frm_daten.'+field+'.value.length');
if (numCharacters > maxlimit) {

var extraCharacters = numCharacters - maxlimit;

var msg = 'You have entered ' + extraCharacters + ' extra characters in the ' +
fieldname + '. The maximum is ' + maxlimit;

alert(msg);
}
}
</script>

Friday, November 12, 2004

Javascript - confirm code - e.g. Are you really sure you want to cancel your changes?

The good old javascript confirm e.g. Are you really sure you want to cancel your changes?

Place this in the header part of the html:

<html>
<head>
<script LANGUAGE="JavaScript">
<!--
// Confirm user wants to cancel the changes
function confirmCancel()
{
var cancelChanges=confirm("Are you sure you wish to cancel your changes?");
if (cancelChanges)
return true ;
else
return false ;
}
// -->
</script>
</head>
<body>
<form name="form1" method="post" action="">
<input TYPE="SUBMIT" name="sub_cancel" value="Cancel" onClick="return confirmCancel();">
</form>
</body>
</html>



Add the text in bold to your submit button.

Thursday, October 21, 2004

Looping through ASP Server Variables

Place this code in the body of your asp file and run it. It will then display all the server variables.

<%

dim obj

for each obj in Request.ServerVariables

response.write "Object Name: " & obj & "<BR>"
& "Object Value: " & Request.ServerVariables(obj) &
"<BR><BR>"

next


%>