|
|||||||
| JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...) |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Create Shortcut on Dekstop via Javascript
Hi,
I'm currently testing a feature that is enabling a shortcut on the desktop. However, I'm stuck at selecting the icon for the shortcut as by default it will show the IE icon. Can anyone help me on this. This is the coding created for the shortcut <script language="Javascript"> var WshShell = new ActiveXObject("WScript.Shell"); strDesktop = WshShell.SpecialFolders("Desktop"); var oShellLink = WshShell.CreateShortcut(strDesktop + "\\shorcut.url"); oShellLink.TargetPath = "http://myurl.com"; oShellLink.Save(); </script>
|
|
#2
|
|||
|
|||
|
Simply name your icon "favicon.ico" and place it in your root directory.
Last edited by Stone_Man; 09-13-2005 at 07:58 AM. |
|
#3
|
||||
|
||||
|
You should place that code inside of
if (ActiveXObject) {} in order to avoid errors in browsers that are not IE running on Windows.
__________________
Stephen Free Computer Help, blog, forum Web design ebooks and software JavaScript scripts and tutorials |
|
#4
|
||||
|
||||
|
Here's a helpful link to convert your BMPs, PNGs, etc into ICOs FOR FREE! and without downloading software!
http://www.html-kit.com/e/favicon.cgi After you select a picture from your hard-drive and hit the "Generate Favicon.ico" buttoon to save the ICO file to your desktop, just click the "download favicon" button and it will download to your desktop as a ZIP file containing both a PNG format preview of your ICO and the actual ICO along with a readme. Enjoy!
__________________
Ultimater XMLHttpRequest: Specification | xmlhttp object | open and onreadystatechange order | String.prototype.toXMLDocument | Sarissa | Prototype | Dojo Broadening one's horizons: 24ways.org Note I have a bad habit of editing my posts hours at a time and hours later. Last edited by Ultimater; 09-13-2005 at 05:35 PM. |
|
#5
|
|||
|
|||
|
(1) If you want to add a true shortcut in IE, you can create a text file with a .URL extension with its content in INI file format.
Code:
[InternetShortcut] URL=http://www.webdeveloper.com IconIndex=0 IconFile=C:\MyFolder\MyProgram.exe The icon file can be a .ico or a .exe with an embedded icon. Just a guess but to add an icon to your existing code (your code creates the .url file) the following example is from the msdn library: Code:
<script language="JScript">
var WshShell = WScript.CreateObject("WScript.Shell");
strDesktop = WshShell.SpecialFolders("Desktop");
var oShellLink = WshShell.CreateShortcut(strDesktop + "\\Shortcut Script.lnk");
oShellLink.TargetPath = WScript.ScriptFullName;
oShellLink.WindowStyle = 1;
oShellLink.Hotkey = "CTRL+SHIFT+F";
oShellLink.IconLocation = "notepad.exe, 0";
oShellLink.Description = "Shortcut Script";
oShellLink.WorkingDirectory = strDesktop;
oShellLink.Save();
</script>
Code:
<script language="Javascript">
function setBookmark(url,str){
if(str=='')str=url;
if (document.all)window.external.AddFavorite(url,str);
else alert('Press CTRL and D to add a bookmark to:\n"'+url+'".');
}
</script>
<input type="button" value="Add to Favorites"
onclick="setBookmark( self.location.href , document.title )">
Last edited by zencoder; 09-20-2006 at 11:13 AM. |
|
#6
|
|||
|
|||
|
Bookmarks in Mozilla, Firefox and Opera
This handy script adds a bookmark link for mozilla opera and firefox:
Code:
<script language="JavaScript1.2" type="text/javascript">
function AddBookmarkLink() {
title = "Webpage Title";
url = "Webpage URL";
if (window.sidebar) {
// Mozilla Firefox Bookmark
window.sidebar.addPanel(title, url,"");
} else if( window.external ) {
// IE Favorite
window.external.AddFavorite( url, title);
} else if(window.opera && window.print) {
// Opera Hotlist
return true;
}
}
if (window.external) {
document.write('<a href ="javascript:AddBookmarkLink()");">Add to Favorites</a>');
} else if (window.sidebar) {
document.write('<a href = "javascript:AddBookmarkLink()");">Bookmark Page</a>');
} else if (window.opera && window.print) {
document.write('<a href = "javascript:AddBookmarkLink()");">Add Bookmark</a>');
}
</script>
Last edited by zencoder; 09-20-2006 at 11:08 AM. |
|
#7
|
|||
|
|||
|
Check out this: The Ultimate Add Bookmark Script
zencoder, please read Guidelines and Suggestions for Posting on Web Development Forums.
__________________
Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around. Check out my blog. |
|
#8
|
|||
|
|||
|
Kravitz,
Quote:
Quote:
|
|
#9
|
|||
|
|||
|
Quote:
Quote:
__________________
Learn CSS. | SSI | PHP includes | X/HTML Validator | CSS validator | Dynamic Site Solutions Design/program for Firefox (and/or Opera), apply fixes for IE, not the other way around. Check out my blog. |
|
#10
|
|||
|
|||
|
Quote:
Thanks for the tip! |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|