Kangry.com [insert cool graphic here]
home | Topics | Logout | Search | Contact | ?? Kangry ?? | Bandwitdh
Topics:
DVR
nvrec
Mplayer
Links
Misc
Commands
Humor

Name

Password

New user

uploaded files
(links)-> (Parent)->Javascript code samples submited by Russell Wed 25 Jan 06
Edited Thu 05 Jun 14
Web kangry.com
This is a collection of stuff I had to lookup, so I put it here so I won't have to do that again.

Find in string ( would be find(haystack,needle) in a real language)
  if (haystack.indexOf(needle)>0)
                {do something};
Document url info:
document.location.href
Move object to absolute location on screen:
Assumes the image has the id=xyzzy and has style='position:absolute;'

var moveMe = document.getElementById("xyzzy");
moveMe.style.left = xPos + "px";
moveMe.style.top = yPos + "px";
test if Varible exists in javascript
find the absolute (x,y) of an image (IE safe)

This one was an annoying 'gotcha':
in HTML/CSS the code is :
text-decoration: line-through
But in javascript the it turns out the code is:
object.style.textDecoration="line-through";
The dash is dropped, and the D is uppercased... How the F*ck was I supposed to just magicly know that ??

test (dumps all the style atributes of the link into an alert box)
The code:
function dump_propertys(object_id){
var object_to_dump = document.getElementById(object_id);
var message="";
for(n in object_to_dump.style)
   {
     message=message+n+" "+object_to_dump.style[n]+";";
   };
alert (message);
}
Javascript submit form The Archive has it This is a simple trick that will let you have a simple text link submit a form. sadly it should be a one line call, but this works.
Read the value of a radiobutfon
I found a good example here finding the value of a radio button
function get_radio_value()
{
var rad_val="";

for (var i=0; i < document.form-name.name-of-radio-button-array.length; i++)
   {
   if (document.form-name.name-of-radio-button-array[i].checked)
      {
      rad_val = document.form-name.name-of-radio-button-array[i].value;
      }
   }
return rad_val;
}
This little trick goes through the existing buttons and if it finds one checked (selected) it returns that value. Note: you must actually set the value attribute in the html for this to work ;-)
force javascript to treat a string as a number
number=parseInt(string)

Replace text/html on a page
document.getElementById('area_id').innerHTML = 'new text/html';
Requires that you have an area predefined
<span id='area_id'>This text will be replaced</span>
also works with div.


Replys:
simple javascript/jquery sideshow with image fade (Russell)
Get url query paramaters in javascript (Russell)
Disable print and copy from webpage with javascript/css (Russell)
javascript add selection box (Russell)
javascript/jquery trigger input event (Russell)
javascript/jquery image slider anythingslider, time picker (Russell)
Very Impressive Javascript code animations (Russell)

Add comment or question...:
Subject:
Submited by: NOT email address. Leave blank for anonymous    (Spam Policy)

Enter Text: (text must match image for posting)




This file (the script that presented the data, not the data itself) , last modified Wednesday 03rd of December 2014 09:40:39 AM
your client: CCBot/2.0 (http://commoncrawl.org/faq/)
current time: Wednesday 23rd of August 2017 05:11:46 PM