JavaScript http://www.mvps.org/dmcritchie/firefox/javascript.txt
started 2006-12-16
Go to home page using Script:
Link to go to home page:
Go HOME
javascript:alert("Hello World");
Test at location bar: to provide directory of
javascript:alert("location.href.substring(0,location.href.substring(0,location.href.length-1).lastIndexOf('/')+1))
Test with home page, http://www.mvps.org/dmcritchie/firefox.htm,
on the location bar. The above script ("ssd:")
returns http://www.mvps.org/dmcritchie/firefox/
Test at location bar: list complete url
javascript:alert("href: "+location.href);
Test at location bar: list fragment-id including # mark
javascript:alert("hash: "+location.hash);
Test at location bar: list full pathname
javascript:alert("pathname: "+location.pathname);
Test at location bar: list host (i.e. www.ibm.com)
javascript:alert("host: "+location.host);
Test at location bar: list protocol name (i.e. http:)
javascript:alert("protocol: "+location.protocol);
Directory name up one level
javascript:alert(location.href.substring(0,location.href.substring(0,location.href.length-1).lastIndexOf('/')+1))
http://www.java2s.com/Tutorial/JavaScript/0320__Location/0020__Location.htm
http://docs.sun.com/source/816-6408-10/location.htm
Questions on JavaScript: comp.language.javascript or comp.infosystems.www.authoring.html
Show source code
javascript:alert(document.body.innerHTML)
here is a bookmarklet that uses the full pathname
name: archive: Internet Archive Wayback Machine
location: javascript:location%20=%20'http://web.archive.org/web/*dc_/'+escape(location);%20void%200
keyword: archive:
description: wayback machine at archive.org
wso:
javascript:location%20=%20'http://www.websiteoptimization.com/services/analyze/wso.php?url='+escape(location);%20void%200
want to make the page open in a new location
javascript:Qr=document.selection.createRange().text;if(!Qr){void(Qr=prompt('Keywords...',''))}if(Qr)window.open('http://google.com/search?hl=en&ie=UTF-8&q='+escape(Qr));void(0);
a bookmarklet to search at the same domain
name: ss: Site Search - search within site
location: javascript:void(location.href='http://www.google.com/search?&q=site:'+location.href.split(%22/%22)[2]+'+%s&newwindow=1&sourceid=firefox')
keyword: ss:
description: http://lifehacker.com/software/geek-to-live/geek-to-live-fifteen-firefox-quick-searches-129658.php
Test at location bar: list domain with prefix
javascript:alert(location.href.split(%22/%22)[2])
Test at location bar: node after domain
javascript:alert(location.href.split(%22/%22)[3])
Test at location bar: next node after that
javascript:alert(location.href.split(%22/%22)[4])
a bookmarklet to place you at one directory level above where you are at (go to the containing directory)
name: up: Up a Directory
location: javascript:void(location.href=location.href.substring(0,location.href.substring(0,location.href.length-1).lastIndexOf('/')+1))
keyword: up:
description: http://www.jobmachine.net/fjamindex.htm?bookmarklets/Ebookmarklets.htm~mainframe
Test at location bar:
javascript:alert(location.href.substring(0,location.href.substring(0,location.href.length-1).lastIndexOf('/')+1));
javascript:
with(location)
href=protocol+"//"+host
+pathname.substring(0,
pathname.lastIndexOf("/",pathname.length-2)+1)
Place url into sidebar (actually it brings up Bookmark add dialog to create bookmark that does that)
javascript:window.sidebar.addPanel('title of sidebar','url of sidebar panel','');
cheatsheet in sidebar
LIKE REDIRECTION BUT IT IS A FAKE
Yahoo
javascript:{alert('Hello World!');}
Use the encodeURIComponent to turn spaces into "+", mask control characters and punctuation, etc.
javascript:{alert(encodeURIComponent(document.title)+" \n"+encodeURIComponent(location.href)) ;}
The rendition of the above might look like this for my firefox.htm page
Firefox%20Customizations%20(Notes)
http%3A%2F%2Fwww.mvps.org%2Fdmcritchie%2Ffirefox%2Ffirefox.htm%23ext_table
javascript:{alert(document.title+" \n"+location.href) ;}
Rendered as follows:
Firefox Customizations (Notes)
http://www.mvps.org/dmcritchie/firefox/firefox.htm#ext_table
javascript:{alert(encodeURIComponent(location)+" \n"+location) ;}
The rendition of the last one in test version might look like this
file%3A%2F%2F%2Fc%3A%2Fcopiedsite%2Fdmcritchie%2Ffirefox%2Fjavascript.txt
file:///c:/copiedsite/dmcritchie/firefox/javascript.txt
and in the production version might look like this
http%3A%2F%2Fwww.mvps.org%2Fdmcritchie%2Ffirefox%2Fjavascript.txt
http://www.mvps.org/dmcritchie/firefox/javascript.txt
http://www.mvps.org/dmcritchie/firefox/kws.htm#related
http: javascript:alert(location.href.split(%22/%22)[0])
javascript:alert(location.href.split(%22/%22)[11])
www.mvps.org javascript:alert(location.href.split(%22/%22)[2])
dmcritchie javascript:alert(location.href.split(%22/%22)[3])
firefox javascript:alert(location.href.split(%22/%22)[4])
firefox.htm#related javascript:alert(location.href.split(%22/%22)[5])
javascript else if statement condition - adding conditions to javascript if statement
http://www.webdevelopersnotes.com/tutorials/javascript/javascript_else_if.php3
=================================================
==Replacement in Bookmarklets==
M: convert abcdotdefatgmaildotcom to abc.def@gmail.com
javascript:void(window.location.reload(false));(function()%20{var%20str="%S";str=str.replace("Name:%20%20%20%20","");str=str.replace("Email:%20%20%20","<");str=str.replace(/dot/gi,".");str=str.replace("at","@");prompt("Ready%20to%20copy%20to%20clipboard",str+">");})();
hightlight:word Highlight the word
javascript:{var%20HLT='h04j73d';W2={h:function(Q){var%20db=document.body,sb='',tm=Q,sm='/('+escape(tm)+')/gi';se='';void(db.innerHTML=db.innerHTML.replace(eval(sm),sb+'$1'+se))}};Q=prompt('Find%20text:',document.selection.createRange().text);if(Q){W2.h(Q)};window.status='Highlighted%20#'+document.getElementsByName(HLT).length+'%20matches.';}void(0);
--source-- http://www.gate2.net/TnT/Bookmarklets.html
next: Next (article)
javascript:with(location){u=href.split(/(\d+)(\D*)$/);if(u.length!=1){n=u[1];l=n.length;n=String(parseInt(n.replace(/^0*(.)/,'$1'))+1);if(u[1].charAt(0)=='0')while(n.length
You have JavaScript turned OFF. You may have trouble rendering pages elsewhere
because JavaScript is OFF and especially those at http://addons.mozilla.org