"What if? Why not? Challenge the Convention! Let's do some incredible things!"  More Quotes

Welcome to Aspire Knowledge Central (AKC)

   Home   Public Library   Author Content

Choose a data format:   classic-xml   object-xml   embedded-xml   text   excel

CS-JavaScript

0) Javascript journal (31-May-19)

Javascript journal

1) Polymer (25-Jul-17)

Polymer

2) Web Components (25-Jul-17)

Web Components

3) React (23-Jul-17)

React

4) Understanding cookies (3-Jul-17)

Revisit Understanding Cookies

5) Javascript try, catch, and console (25-Jun-17)

Javascript try, catch, and console

6) working with Curl (24-Jun-17)

working with Curl

7) Whats up with new UX components: 2017 (17-Jun-17)

Whats up with new UX components: 2017

8) Sometimes Abstracted Object Oriented code is really pretty! (25-Jun-14)

Consider this


function Pair(inMin, inMax)
{
    this.min = inMin;
    this.max = inMax;
}

Which would let me use


var somepair = new Pair(5,10);
somepair.min => 5
somepair.max => 10

See this function now


function getTotalScaledScorePair()
{
    var rpair = getReadingScaledScorePair();
    var wpair = getWritingScaledScorePair();
    var mpair = getMathScaledScorePair();
    
    var tmin = rpair.min + wpair.min + mpair.min;
    var tmax = rpair.max + wpair.max + mpair.max;
    return new Pair(tmin, tmax);
}

9) Working with radio buttons (25-Jun-14)

Working with radio buttons

10) Web Security Constraints (11-Jun-14)

Web Security Constraints

11) js: Regulare expressions in java script (2-Jun-14)

http://www.regular-expressions.info/javascriptexample.html

Regulare expressions in java script

12) Another javascript example - checkboxes, arrays, strings, trim (24-May-14)

1. How to trim a string
2. How to use arrays
3. How to split a string
4. Uses an aspire function called getSelectedCheckBoxValues

13) submitting http forms (16-May-14)

submitting http forms

14) javascript common errors (6-May-14)

For mere mortals or the occasional or reluctant practitioner of Javascript this page documents some common errors. Needless to admit that I made all of them! More than once!

15) How to escape, encode special characters in javascript strings (21-Apr-14)

http://www.kingsley-hughes.com/tech/script/javascript/esc.asp

Some times when server side needs to write out a string variable that initializes a javascript string it is important to know how to escape strings.

The usual html escape and unescape are either too heavy handed and require probably special handling.

A good approach may be just use the back slashes to skip the quote double or single quotes.

16) Scoping of variables in Javascript (21-Apr-14)

Scoping of variables in Javascript

17) How to construct a local file url for chrome? (20-Jun-13)

How to construct a local file url for chrome?

18) javascript and href (14-Oct-12)

javascript and href

19) Sample javascript code (12-Oct-12)

Description to be entered

20) line1 character1 invalid: a javascript error (12-Oct-12)

line1 character1 invalid: a javascript error

21) Creating a function object from its string name (10-Oct-12)

Creating a function object from its string name

22) How do you implement inheritance in javascript? (8-Oct-12)

How do you implement inheritance in javascript?

23) whats up with coffee script? (7-Oct-12)

whats up with coffee script?

24) inner function in javascript (7-Oct-12)

inner function in javascript

25) log-in patterns (4-Oct-12)

log-in patterns

26) Collected notes on JQuery (1-Oct-12)

Use this URL to see a lot of articles on JQuery

27) What is HAML? (12-Jun-12)

What is HAML?

28) javascript function index of any one character from a string? (9-May-12)

javascript function index of any one character from a string?

29) Tokenizing strings in javascript (5-May-12)

Tokenizing strings in javascript

30) Nature of Javascript (28-Apr-12)

Nature of Javascript

31) js: sample html with script (20-Apr-12)


<html>
<head>
<script type="text/javascript" src="/webapp/scripts/file.js"></script>

<script>
function test(field)
{
	alert("hello");
}
</script>

</head>
<body>
<form>
<p>
numeric field 1: 
<INPUT type="text" name="test1" size="20" onblur="test(this)">
</p>

<p>
numeric field 2: 
<INPUT type="text" name="test2" size="20">
</p>
</form>
</body>
</html>

32) Understand javascript nulls (25-Feb-12)

Understand javascript nulls

33) How to replace tabs with spaces (10-Nov-11)

How to replace tabs with spaces

34) how to disable an html link? (22-Jun-11)

how to disable an html link?

35) how can I change a mouse pointer? (16-Jun-11)

how can I change a mouse pointer?

36) how can i control the margin of a div's children (16-Jun-11)

how can i control the margin of a div's children

37) Can I specify multiple classes on an html tag (14-Apr-11)

Can I specify multiple classes on an html tag

38) javascript and checksum (7-Mar-11)

javascript and checksum

39) How to target an ie tab from javascript (20-Jan-11)

We ran into a usecase where a user has to explicitly target a tab in ie. For example users have logged into salesforce.com cloud in one window. These users are then taking calls in that window. However same users are using another internet application to complete their work. It would be messy to open up these multiple windows every time work needs to be done.

It is probably better to target just one window and the user transferred to one window. Better yet to target a specific tab.

So started my search. I thought it ought to be simple. As it turned out there doesnt seem to be a good way to do this through regular unsigned javascript in ie7. I did find a way to do this in firefox.

ie seem to control tab vs new window purely through user configuration. Users can choose to set a global ie option to open new windows targeted by "_blank" to either an actual new window or a tab. Once they set this option as tab then the simple window.open(url) will open that url in a new tab.

I still want to force to open in a new tab. Perhas I will find a way through signed javascript. that is for another day or week.

If you are further curious what follows is my research and notes on how I came to this conclusion. Click on the item above to see that research.

40) How to write ie controls (20-Jan-11)

How to write ie controls

41) How to set body onload from javascript (1-Jan-11)

How to set body onload from javascript

42) html: HTML tag reference (31-Dec-10)

http://www.mountaindragon.com/html/tables2.htm#TOC

Commonly used html tag reference
tables
text
font

43) How to use Firebug (14-May-10)

How to use Firebug

44) How to control ie with signed scripts (14-May-10)

How to control ie with signed scripts

45) Transparent text (26-Aug-09)

Transparent text

46) What html element generated the event? (10-Aug-09)

What html element generated the event?

47) How to initialize a javascript object (8-Aug-09)

How to initialize a javascript object

48) what are bookmarklets (8-Aug-09)

what are bookmarklets

49) Javasscript versions (8-Aug-09)

Javasscript versions

50) Javascript and name spaces (2-Aug-09)

Javascript and name spaces

51) New OO Javascript (1-Aug-09)

New OO Javascript

52) javascript isDefined? isVariableDefined? isFunctionDefined? (16-Apr-08)

Conditional exectuion of functions

isDefined?

isVariableDefined?

isFunctionDefined?

53) Run tidy online (25-Jul-06)

http://validator.aborla.net/

To see if your page is xthml. Also gives an xhtml version of output.

54) Setting up a footer using CSS (28-Apr-06)


<style>
div.footerDiv1
{
text-align:right;
border-top:1px solid
}

div.footerDiv1 p
{
    margin:0 0 0 0;
}
</style>

<div class="footerDiv1">
<p>Test1
<p>Test1 kddkkkd ddd
<p>Test1 kddkkkd ddd
</div>

55) understanding http 302 errors (4-Apr-06)

http://www.checkupdown.com/status/E302.html

Will the java url libraries deal with this correctly?

>> Tuesday, April 04, 2006 6:44:53 PM - Comments by satya

Codes that need to be handled

Handling redirects manually through java api

301 Moved Permanently. HttpStatus.SC_MOVED_PERMANENTLY 
302 Moved Temporarily. HttpStatus.SC_MOVED_TEMPORARILY 
303 See Other. HttpStatus.SC_SEE_OTHER 
307 Temporary Redirect. HttpStatus.SC_TEMPORARY_REDIRECT 

56) Javascript notes (18-Mar-06)

Description to be entered

57) js: How to get a cursor position in a text field (18-Mar-06)


function getCursorPositionInTextField(textFieldObj) 
{
	//This is required if you were to be clicking on a button to invoke this
	//otherwise your selection is the button
	textFieldObj.focus();
	
	textrange = document.selection.createRange().duplicate();
	//You may have to make sure the selection and focus is with your object
	//because the selection is document level entity.
	//if (textrange.parentElement() != textFieldObj)
	//{
	//	alert("Sorry you are not the field");
	//}
	
	var i=0;
	while(textrange.move("character",1) == 1)
	{
		i++;
	}
	return textFieldObj.value.length() - i;
}

58) js: sample html (17-Mar-06)


<html>
<head>
</head>
<body>
</body>
</html>

59) Understanding/using Cookies in javascript (10-Jan-06)

http://www.quirksmode.org/index.html?/js/cookies.html

Where you find one, you find many

//************************************************
// createCookie
// Borrowed from the internet (Scott Andrew)
//************************************************
function createCookie(name,value,days)
{
   if (days)
   {
      var date = new Date();
      date.setTime(date.getTime()+(days*24*60*60*1000));
      var expires = "; expires="+date.toGMTString();
   }
   else var expires = "";
   //document.cookie = name+"="+value+expires+"; path=/";
   document.cookie = name+"="+value+"; path=/";
}

//************************************************
// readCookie
// Borrowed from the internet
//************************************************
function readCookie(name)
{
   var nameEQ = name + "=";
   var ca = document.cookie.split(';');
   for(var i=0;i < ca.length;i++)
   {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
   }
   return null;
}

60) How to figure out screen resolution in javascript (29-Nov-05)

http://www.pageresource.com/jscript/jscreen.htm

How to figure out screen resolution in javascript

Example

if ((screen.width>=1024) && (screen.height>=768))
{
 window.location="highres.html";
}
else
{
  window.location="lowres.html";
}

61) js: How to encode decode strings in javascript (4-Nov-05)

http://scriptasylum.com/tutorials/encdec/encode-decode.html

you will need to use the escape and unescape functions.

62) How to hide and unhide html sections/controls such as "div" (12-Oct-05)

This articles explores a couple of ways of hiding div sections in an html document. The discussion will apply to other html controls as well that exhibit "display" and "visibility" properties. The article also contains sample code.

63) A bit of javascript that demonstrates OO programming, string parsing, and URL splitting for Java programmers (3-Sep-05)

It is surprising sometimes what I end up learning

64) Exercising Children of an html node in javascript (14-May-05)

//************************************************************
//Returns a string value 
//of the url for the image of an anchor object
//************************************************************
function getImageSrc(saveAnchor)
{
   //alert("Working with an anchor:" + saveAnchor.href);
   imgElement = saveAnchor.children[0];
   if (imgElement == null)
   {
      //alert("Warning: this saveanchor does not have an image element");
      return null;
   }
   //alert("An image anchor found");
   //alert("The source of the image is: " + imgElement.src);
   return imgElement.src;
}

65) How to debug http headers (6-May-05)

http://www.blunck.info/iehttpheaders.html

66) Flash notes (15-Apr-05)

A beginers quest for flash and what is possible

67) How to capture the enter key on a browser page (15-Apr-05)

Use document's capture events.

68) How to send an email from a web page? (25-Jan-05)

http://www.utoronto.ca/webdocs/HTMLdocs/Book/Book-3ed/chap6/mail.html

69) Principles of HTML design for web engineering (19-Dec-04)

Read this article for engineering data base driven web sites.

70) js: How to write a redirect web page? (5-Dec-04)

How to parse a url using javascript

How to get a relative url from any url address

How to use a static html page to redirect to a different web address

71) Jumping to an anchor or how to jump to the bottom of a page (16-Oct-04)

Create an anchor with a name at the bottom


<a name="bottom"> </a>

Jumpt to it from anywhere


<p><a href="#bottom">Go to the bottom</a></p>

72) Understand and research this a bit more (12-Jul-04)

tbd


<script language="JavaScript" type="text/JavaScript">
function setHTML(e) {
	if (e) {
		document
		.getElementById("example_area")
		.innerHTML
		=document
		   .getElementById(e)
		   .innerHTML;
	}
	else {
		document
		 .getElementById("example_area")
		 .innerHTML=" ";
	}
}
</script>

73) Play around with the visibility of divisions in javascript? (12-Jul-04)

tbd

74) Encoding/decoding in javascript (17-Jun-04)

http://sislands.com/coin70/week6/encoder.htm

75) Learning HTML for kids by Jill Jeffers Goodell (29-Mar-04)

http://www.goodellgroup.com/tutorial/

Introduction: Structure of Tutorial
Chapter 1: What is HTML anyway?
Chapter 2: Basic concepts
Chapter 3: Primary tags
Chapter 4: Creating your first Web page
Chapter 5: Basic text formatting
Chapter 6: Lists
Review #1
Chapter 7: Attributes: Adding interest to your page
Chapter 8: Advanced Text Formatting
Review #2
Chapter9: Links down the street to around... 
Chapter 10: Graphics
Chapter 11: Building pages with tables
Chapter 12 More on tables

76) Looks like a decent guide for HTML (14-Oct-03)

http://www.pageresource.com

77) Some java script utilites from simplythebest (19-Aug-03)

http://simplythebest.net/info/dhtml_scripts.html

1. time and date scripts
2. menu scripts
3. Javascript documentation links
4. A plug for dhtml

78) How to create a trim function for a string (4-Aug-03)

Description to be entered

79) Example java script 1 (4-Aug-03)

How to include a javascript library
How to include a style sheet
A handful of javascript functions

80) How to redirect to a different page on reload? (12-Jul-03)

<html>
<head>
<script>
	function redirectTo()
	{
		location.replace("http://216.187.231.34/akc");
	}
</script>
</head>

<body onload="redirectTo()">
</body>
</html>

81) javascript guide from navigator 3.0 (28-Jun-03)

http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/index.html

82) Java script 1.4 guide (28-Jun-03)

http://devedge.netscape.com/library/manuals/2000/javascript/1.4/guide/

83) Links to a list of javascript guides (28-Jun-03)

http://devedge.netscape.com/central/javascript/

Java script guides from 1.3 to 1.5