Yogesh's Blog

Sharing me with blog…
Archive for June, 2010

June 30th, 2010

Prevent browser closing

1 Comment, Javascript, by Yogesh.

Due to some reason,  sometime we want to prevent closing of browser. Actually for security reason, we can not force client to keep browser window open, but what we can do: we can ask client confirmation for it. So to prevent closing of browser window, following javascript code can be used. This works in IE, Mozilla, Safari (Checked with IE6, IE7, IE8, Mozilla firefox 3.5, Safari 5) <SCRIPT LANGUAGE=”JavaScript”> window.onbeforeunload = function(e) { e = e || window.event; var message = “Your message here”; e.returnValue = message; return message; }; </SCRIPT> Here e.returnValue = message; does not work in safari but return message; does. When the alert will come? – On closing browser using cross button (X) – On refreshing browser (browser’s refresh button or F5) – On hitting address bar (either address is changed or not) – Going back (By hiting back button or Backspace) – By clicking link When alert will not come? – By clicking on link to open pop-up window Now here comes the condition that you don’t want to show alert when user clicks on particular link to open some other page in same window. Do by this: <SCRIPT LANGUAGE=”JavaScript”> var showPreventMessage = true; window.onbeforeunload = function(e) { e = e || window.event; if(showPreventMessage){ var message = “Your message here.”; e.returnValue = message; return message; } else { // it means here you don’t want to show message. } }; function disablePreventMessage(){ showPreventMessage = false; } </SCRIPT> Now just call the disablePreventMessage function on the onClick event of link you…

Many time in java development, we need to find out the java class availability in jar file. If there is one jar file then looking class in that is easy, but suppose there are lots of libraries (lots of jars) then to search in those libraries, really really tough task. Here is the solution for it, using JarScan… Steps to search: Put JarScan jar file in some location (Example: D:\Utils\)  (download JarScan from here) Open command prompt Use following command Syntex: java -jar <location-pointing-to-downloaded-jar-file> -dir <location-to-search-class-in> -class <classname-only-name-or-with-package> Example 1: java -jar D:\Utils\jarscan.jar -dir D:\myLibraries\ -class MyClassToSearch Example 2: java -jar D:\Utils\jarscan.jar -dir D:\myLibraries\ -class com.mycompany.mypackage.MyClassToSearch You will get list of library files who will be scanned and also finally detail of libraries where specified class is found. Details uses and syntex: Command: java -jar jarscan.jar [-help | /?] [-dir directory name] [-zip] [-showProgress] <-files | -class | -package> <search string  1> [search string 2] [search string n] Command Help: Command option Description -help or /? Displays this message. -dir The directory to start searching from default is “.” -zip Also search Zip files -showProgress Show a running count of files read in -files or -class Search for a file or Java class contained in some library. i.e. HttpServlet -package Search for a Java package contained in some library. i.e. javax.servlet.http search string The file or package to search for. i.e. see examples above

June 18th, 2010

Create Ringtone for iPhone

No Comments, iPhone, iTunes, by Yogesh.

It is not just easy to use any of songs as your ringtone in iPhone. Ringtones for iPhone are different and stored in some internal specific location in phone. As apple sells ringtone, and direct use/transfer is not allowed in iPhone so you can not use any ringtone. But here is the trick to create your own ringtone and use that in your iPhone. Open iTunes Listen up the song and note-down start and stop time for ringtone Right click on song and choose “Get Info” Go to “Options” tab Enter start and stop time as you noted earlier (Use maximum 40 seconds duration) Click on song ***Click on “Advanced” of top menu bar -> “Create AAC version” Now iTunes will create its AAC version, wait for its completion. After its completion, you can delete the created file. Don’t delete from disk (Choose “Keep File” in delete confirmation) Now go to iTunes internal data folder i.e. folder where iTunes keeps the songs and other stuff. Go in “Music” folder ->”<Artist name>” -> “<Album name>” -> File with extension .m4a Rename it and change its extension from .m4a to .m4r Now double click on renamed file, file will be added to ringtone in iTunes and also will be moved to ringtone folder of iTunes data. Now connect iPhone and sync with ringtones. Note:  -> Point 7 may differ in various iTunes versions. In older version, it can be found just in context menu by right clicking on song. -> This will not work for songs brought…

June 12th, 2010

First Hello In Blog

No Comments, Uncategorized, by Yogesh.

Hello Friends, Welcome to my blog page. Here i will share my experiences with you. Stay in touch… — Yogesh