@Commands in JavaScript - hassle free!

@Commands in JavaScript - hassle free!

Facts: Domino can generate Javascript equivalents for @Commands executed by links, buttons, etc.

Problem: In order to use these in JavaScript where YOU want (form.onsubmit, called by generated JavaScript, etc.) you have few viable options (hidden layers, "sacred" subforms, etc.). Previous solutions get the job done (usually), but can create more headaches than they are worth.

Solution: Using a simple process, you can access the power of @Commands in JavaScript without the usual headache.
1. Create an action hotspot. The contents can be spaces, or (my preference) a passthrough HTML comment indicating the @Command being setup.
2. In the hotspot's frame property (properties window, first tab), enter some kind of identifier for the @Command being setup. Don't use the @ symbol, though. Javascript won't like it.
3. In the onLoad event of the window, cycle through the document.links array looking for the link whose target matches the identifier you used.
4. Once you have found the right link, you can assign it's onclick event to whatever you want, and call it however you want. Note that in order to assign the onclick event to another JavaScript object, you must refer to it all in lowercase, and omit the parentheses (otherwise you will assign the return value of the onclick event you want to assign).

Q&A:
Q: What if users click on the link?
A: The link doesn't show. It's invisible. In my tests, it

    Requires Free Membership to View

    Register today to access targeted resources from our editorial writers and independent industry experts focused on Lotus Domino, Notes, Workplace and other related technologies.

    By submitting your registration information to SearchDomino.com you agree to receive email communications from TechTarget and TechTarget partners. We encourage you to read our Privacy Policy which contains important disclosures about how we collect and use your registration and other information. If you reside outside of the United States, by submitting this registration information you consent to having your personal data transferred to and processed in the United States. Your use of SearchDomino.com is governed by our Terms of Use. You may contact us at webmaster@TechTarget.com.

occupies NO space and cannot be clicked.
Q: What about the target frame? It doesn't exist. Is that a problem?
A: No. Again, it cannot be clicked.
Q: Where have you tested it?
A: NS 4.7 and 6.0-1, and IE 5.5. I would expect similar for IE 4.


This was first published in October 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.