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 Wed 23 Apr 08
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 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.

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 Thursday 29th of April 2010 09:02:13 AM
your client: CCBot/1.0 (+http://www.commoncrawl.org/bot.html)
current time: Sunday 05th of September 2010 04:00:54 PM