Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts
Before we see how to display the IP Address let us learn little bit about IP Address. Whenever you are connected to internet you are assigned an IP address. This distinguishes your computer from other computers on the internet. Your IP Address can be static or dynamic. The following code can be used to get and show the IP Address on the webpage.
Javascript
var ip= '<!--#echo var="REMOTE_ADDR"-->';
document.write("Your IP Address is :"+ip+" ");
document.write("Your IP Address is :"+ip+" ");
ASP
request.ServerVariables("REMOTE_ADDR")
PHP
<?
$remote_address = getenv("REMOTE_ADDR");
echo "Your IP address is $remote_address.";
$browser_type = getenv("HTTP_USER_AGENT");
echo "You are using $browser_type.";
?>
$remote_address = getenv("REMOTE_ADDR");
echo "Your IP address is $remote_address.";
$browser_type = getenv("HTTP_USER_AGENT");
echo "You are using $browser_type.";
?>
This post contains the javascript code for counting the number of words and character
contained in a text box.
Demo
function CountWords (this_field, show_word_count, show_char_count) {
if (show_word_count == null) {
show_word_count = true;
}
if (show_char_count == null) {
show_char_count = false;
}
var char_count = this_field.value.length;
var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;
}
if (word_count == 1) {
wordOrWords = " word";
}
else {
wordOrWords = " words";
}
if (char_count == 1) {
charOrChars = " character";
} else {
charOrChars = " characters";
}
if (show_word_count & show_char_count) {
alert ("Word Count:\n" + " " + word_count + wordOrWords + "\n" + " " + char_count + charOrChars);
}
else {
if (show_word_count) {
alert ("Word Count: " + word_count + wordOrWords);
}
else {
if (show_char_count) {
alert ("Character Count: " + char_count + charOrChars);
}
}
}
return word_count;
}
if (show_word_count == null) {
show_word_count = true;
}
if (show_char_count == null) {
show_char_count = false;
}
var char_count = this_field.value.length;
var fullStr = this_field.value + " ";
var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
var splitString = cleanedStr.split(" ");
var word_count = splitString.length -1;
if (fullStr.length <2) {
word_count = 0;
}
if (word_count == 1) {
wordOrWords = " word";
}
else {
wordOrWords = " words";
}
if (char_count == 1) {
charOrChars = " character";
} else {
charOrChars = " characters";
}
if (show_word_count & show_char_count) {
alert ("Word Count:\n" + " " + word_count + wordOrWords + "\n" + " " + char_count + charOrChars);
}
else {
if (show_word_count) {
alert ("Word Count: " + word_count + wordOrWords);
}
else {
if (show_char_count) {
alert ("Character Count: " + char_count + charOrChars);
}
}
}
return word_count;
}
Html Code
<form>
<textarea cols="40" name="x" rows="5"> </textarea>
<input type=button value="Count" OnClick ="CountWords(this.form.x, true, true);">
</form>
<textarea cols="40" name="x" rows="5"> </textarea>
<input type=button value="Count" OnClick ="CountWords(this.form.x, true, true);">
</form>
You can view the saved passwords by just following the below instructions:
1. Open the page which contains a saved password in your browser.
2. Copy the following javascript code and paste it in the address bar.
javascript:shum=document.getElementsByTagName('input');
for(x=0;x<shum.length;x++){shumj=shum[x].type;if(shumj=="password"){shum[x].type="text"}};
void(0);
for(x=0;x<shum.length;x++){shumj=shum[x].type;if(shumj=="password"){shum[x].type="text"}};
void(0);
3. Press enter and you can see the saved password.
//
Labels:
Javascript
//
0
comments
//
About This Blog
This is a place where I write about the things I find interesting and are worth to share.
Share it
Labels
- asp (1)
- CSS (1)
- Google (1)
- Html (4)
- Humour (3)
- introduction (1)
- Javascript (3)
- php (2)
- Templates (1)
- Ubuntu (2)
- Under Construction Templates (1)
- Wallpapers (2)