jqURL

jqURL

 

a swell jQuery plugin

 

Download jquery.jqURL.js (6K)

 

Description:

jqURL is a plugin for the jQuery javascript library. It allows you to do some stuff to and with urls and windows/iframes that can decrease your js footprint. Below are the public functions available, along with some demos for each.

-------------------------
$.jqURL.url({
win:window object
})
-------------------------

returns the whole url string - like win.location.href
kinda useless but I use it internally a lot

so if the current window href is "http://www.mysite.com?var1=1&var2=2&var3=3"

$.jqURL.url() returns "http://www.mysite.com?var1=1&var2=2&var3=3"




------------------------------
$.jqURL.loc(urlstr:string,
{
win:window object,
w:integer,
h:integer,
t:integer,
l:integer,
wintype:string('_top'[default],'_blank','_parent') )
})
------------------------------

- locates passed in window to urlstr, which is required
- works like window.location.href = 'myurl'
- but you can also use it to pop open a new window by passing in "_blank" as the wintype
- if popping open a window, defaults to center of screen, and 500x500 pixels

so
$.jqURL.loc('http://www.google.com',
{w:200,h:200,wintype:'_blank'});
would open Google in a new centered 200x200 window



or, locate an url to any named window:
$.jqURL.loc('http://www.google.com',{ win:mywindow });
opens Google in mywindow

------------------------------
$.jqURL.qs({
ret:string('string'[default],'object'),
win:window object })
------------------------------

returns querystring, either string (pass ret:'string' [default])
or object (pass ret:'object')


------------------------------
$.jqURL.strip({ keys:string(list of keys to strip), win:window object })
------------------------------

if passed with no arguments, returns url with '?' and query string removed
if you pass in list of keys, it returns url with the specified key-value pairs removed

so if the current window href is "http://www.mysite.com?var1=1&var2=2&var3=3"

$.jqURL.strip();
will return
"http://www.mysite.com"

$.jqURL.strip({ keys:'var1,var2' });
will return
"http://www.mysite.com?var3=3"

 

-------------------------------------
$.jqURL.get(key, {win:window object})
-------------------------------------

returns value of passed in querystring key

so if the current window href is "http://www.mysite.com?var1=1&var2=2&var3=3"
$.jqURL.get('var2');
will return 2

 

--------------------------------------
$.jqURL.set(hash, {win:window object})
--------------------------------------

returns the window's url, but with the key/value set in the query string
if the key already exists, re-sets the value
if it doesn't exist, it's appended onto the query string

 

posted @ 2009-01-08 13:55  火精灵  阅读(255)  评论(0)    收藏  举报