Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Wednesday, March 07, 2007

Search Bookmarklets

Hi, I wanted to share my "search bookmarks" with you,
These are very easy to use search functions



//Prototype API
javascript:w=prompt('Search Prototype API');if(w){w=w.replace(/\./g, '/');window.location.href='http://prototypejs.org/api/'+w.toLowerCase();}else void(0);
//PHP REFERENCE
javascript:w=prompt('PHP REFERENCE...');if(w){w=w.replace(/\./g, '/');window.location.href='http://tr2.php.net/manual-lookup.php?pattern='+w.toLowerCase();}else void(0);
//Answers.com
javascript:w=prompt('Answers.com');if(w){w=w.replace(/\./g, '/');window.location.href='http://www.answers.com/'+w.toLowerCase();}else void(0);
//script.aculo.us
javascript:w=prompt('script.aculo.us');if(w){w=w.replace(/\./g, '/');window.location.href='http://wiki.script.aculo.us/scriptaculous/search/?page%5Bname%5D='+w.toLowerCase();}else void(0);
//wikipedia
javascript:w=prompt('Wikipedia.org');if(w){w=w.replace(/\./g, '/');window.location.href='http://en.wikipedia.org/wiki/'+w.toLowerCase();}else void(0);




Its pretty easy to use them just drag-and-drop these links BELOW to you bookmarks toolbar (in every browser, especially in FIREFOX)
Here is the links.

Prototype API
PHP Reference
Answers.com
script.aculo.us
wikipedia

also you can make your own search bookmarks just examine the code.
However, if you need help, feel free to ask.
Have Nice Dayy...

Tuesday, March 06, 2007

Alternative PNG Support for IE6

Hi,
If you are looking for an alternative PNG support for IE6 here is a piece of code.
to use this code you will need the blank.gif
a transparent gif image.

only thing you have to do is,
simply put this function in to your application.
The real matter is calling the function



function pngImages(){
if(document.all){
for(x=0;x < arguments.length;x++){
elm = document.getElementById(arguments[x]);
elm.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale src='" + elm.src + "')";
elm.src = "images/blank.gif";
}
}
}




function should be called after all image elements loaded, or on the body->onload event.

What you have to do is send function a string which is containing the IDs of png images. like this,

pngImages("logo","faq","blog","about","shadws","bckgrd");

Thursday, March 01, 2007

Real-Time Page Editting on Browser.

Hi,
Here is a great piece of code to edit any page you want on browser.


javascript:document.body.contentEditable='true'; document.designMode='on'; void(0);


Just copy this code to the Address bar. when you hit enter you'll get the ability of editing the content of the current web page.

this is a code that most of the WYSIWYG HTML editors uses. I just made is usable for browsers.

Enjoy!!!.

Sunday, February 11, 2007

Extracting all the elements as veraibles ( javascript extract )

hi,
i wrote a code recently that extracts all the id's of the objects as a variables.
ones
you run this function on body->onLoad it gets all the elements and
defines them by giving them their ids as variable names. function acts
like:



var textbox = document.getElementById("textbox");


for all the elements, it gives you the opportunity of using all of them without even defining.
this function has an equal in PHP(a bit different but it's about the same)
anyway here is the code:


function extract(){
var ie =(document.all)? "var " : "";
var allelems = document.body;
for(var x=0;x < allelems.childNodes.length;x++){
if(allelems.childNodes[x].id){
eval(ie + allelems.childNodes[x].id + " = document.getElementById('"+ allelems.childNodes[x].id +"');");
}
}
}


This
function has some problems first one is, it's not a good thing to run
any unnecessary functions at the onload event. it can cause slowing
down.
Secondly it can cause some problems if you give your elements
the allocated names such as, "for","while","if","document" or "window"
as an ID.
In fact this problem can be solved by modifying the code to make it act like
not define the variables as

var textbox = document.getElementById("textbox");
but define them as

var elems = new Array();
elems["textbox"] = document.getElementById("textbox");
elems["textbox2"] = document.getElementById("textbox2");

this
will solve the problem. if you use the function like this you will have
an associative array that contains all the elements.

I know, it's not "so" useful but in some specific situations it might be really useful like downsizing the file size.
any way, i hope it will be useful, see you later.