|
Save Link Method
XML Menu Suite
Build powerful, client-side DHTML menus using XML for data and CSS for style. No JavaScript data! No having to place list elements on every single page of your website! No plug-ins!
Method: CJL_saveLink() Summary: Generic JavaScript method that allows the user to save a link to a page. If the browser is Internet Explorer, a bookmark is saved. If the browser is in the Gecko family, a tab is added to the sidebar. Submitted: 03/01/2003 Created by: CodeHouse.com Browser Compatibility for this method
Demo The demo opens in a new window. To see the source code, use your browser's method of viewing the contents of the page, or save the page to your local machine and view it in an editor. Note that if you download the demo, it will not work properly unless it is run from a server. See the Comments section for more information. Also, non-compatible browsers will take no action when this method is called.
Source Code The source code for this method is contained in the text area below. You can copy and paste it into your own source code. Before using the source code, make sure that you read and agree to the terms of the License Agreement, which will open in a separate window.
Method: CJL_saveLink(anchorId, linkTitle, url, bookmarkText, tabText) Description: The first parameter, anchorId, is the only required parameter. anchorId is the id of an anchor element which has been loaded by the document. The method dynamically inserts default text into the anchor element to create its link. If the browser is Internet Explorer, the default text is "Bookmark Page". If the browser is in the Gecko family of browsers, the default text is "Add to Sidebar". You can change the default text with the bookmarkText and tabText parameters, described below. When the user clicks the link in the anchor, the user can save the link as a bookmark if the browser is Internet Explorer, or as a tab if the browser is in the Gecko family. By default, the link that is saved is the URL of the current page. You can define a custom URL to be saved by supplying your own URL in the url parameter. Example Usage: Allows the user to save a link to the current page. Note that "save_this_page" is the id of an anchor element in the page. CJL_saveLink("save_this_page"); Comments: Keep aware of the fact that probably due to security reasons, Gecko browsers will not allow you to add a local file to the sidebar. Because of this, the demo won't work properly if run locally. Make sure that the target anchor element, specified by anchorId, is loaded into the DOM before calling this method. Accordingly, call this method after the markup for the anchor element or in an onload handler. Keep in mind that Gecko family browsers such as Netscape may not add tabs to the sidebar properly if not installed with the default options. Gecko browsers in general do not work properly unless installed with default options. This method should not cause side-effects for non-compatible browsers. Parameters anchorId:
Required parameter. Target anchor element that will
be used by this method to place the link to save a page. This element
must be loaded into the DOM beforehand.
linkTitle:
Optional parameter. Title to use for the link which
the user saves in the browser. If this parameter is not supplied, the
title will be taken from the document's title.
url:
Optional parameter. The URL of the link which the
user saves in the browser. If this parameter is not supplied, the
URL will be that of the current window.
bookmarkText:
Optional parameter. Specifies the text that Internet
Explorer users will see in the link for the anchor specified by anchorId.
If this parameter is not supplied, the default text used for the link
will be: "Bookmark Page".
tabText:
Optional parameter. Specifies the text that Gecko
browser users will see in the link for the anchor specified by anchorId.
If this parameter is not supplied, the default text used for the link
will be: "Add to Sidebar".
Support If you have any questions, find any bugs, or have suggestions, feel free to contact us. |