Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • Lotus Notes and Domino Application Development wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.0
  • 6.5
  • 8.0
  • 8.5
  • 8.5.1
  • 8.5.2
  • 8.5.3
  • action bar
  • Agents
  • Ajax
  • app dev
  • Application
  • beginner
  • C&S
  • calendaring and scheduling
  • client
  • composite applications
  • Controls
  • converters
  • css
  • Custom controls
  • Data Binding
  • db2
  • design elements
  • dialog boxes
  • Documents
  • Dojo
  • Domino
  • Domino Designer
  • Domino Designer 8.5
  • DXL
  • Eclipse
  • error handling
  • errors
  • extensions
  • FAQ
  • Forms
  • formulas
  • getting started
  • globalization
  • Help
  • html
  • Installation
  • interface
  • internationalization
  • iPhone
  • Java
  • JavaScript
  • localization
  • Lotus Domino Designer
  • LotusScript
  • LotusSphere
  • LotusTechInfo
  • menu bar
  • Mobile
  • new user
  • Notes
  • Notes 8
  • notes.ini
  • NSD
  • OpenNTF
  • partial update
  • performance
  • Pickers
  • Portal
  • presentations
  • programming
  • Redbooks
  • Requested Articles
  • roadmap
  • rooms and resources
  • samples
  • Scripting
  • security
  • tabs
  • templates
  • themes
  • Tips
  • toolbar
  • troubleshooting
  • tutorials
  • validation
  • variables
  • video
  • VideoFest
  • View
  • view control
  • ViewPanel
  • Views
  • web
  • Web apps
  • Web services
  • webdev
  • XML
  • Xpage
  • XPages
  • XPages Extensibility API
  • xsp-config
  • データソース
  • 九州地区ノーツパートナー会
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Designing XPage Applications > Using dojo.style to adjust the style of DOM Nodes
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Using dojo.style to adjust the style of DOM Nodes 

expanded Abstract
collapsed Abstract
Have you ever wished you could set the style of an element programmatically, well using dojo.style now you can.
ShowTable of Contents
HideTable of Contents
  • 1 The Power
    • 1.1 Get the style of a DOM Node
    • 1.2 Set the style of a DOM Node
  • 2 Summary
Have you ever wished you could set the style of an element programmatically, well using dojo.style now you can. Dojo has many tools available to manipulate the DOM programmatically. While you have always been able to do this with JavaScript, sometimes it takes quite a bit of code to do so. While I'm just starting to delve into dojo I have found a method that is a great way of manipulating the style of DOM elements programmatically. By using dojo.style you can get and set the styles on the fly when something occurs (i.e. a click, a page reload, etc.). This makes it possible to have sort of "logic driven" CSS if you will.
 

The Power

dojo.style accepts 3 different parameters depending on what you want to do:
* The ID of the NODE, you can use dojo.byId or just hard-code it or use a variable
* The style parameter you want to get or change (i.e. position, margin, padding, etc.). This can also be an array of elements
* What you want to set the style parameter to

Get the style of a DOM Node


Say you want to get the current style of a DOM Node. You would simply do something like this:
 
dojo.style("ID-Of-DOM-NODE","margin-top");

This would return what the value of "margin-top" is for the ID-Of-DOM-NODE element on the page.
 

Set the style of a DOM Node


So now you want to set the style of a DOM Node on the page. You would do this:
 
dojo.style("ID-Of-DOM-NODE","margin-top","5px"); 

 
You can also set many style elements by passing in an array:
 
dojo.style("ID-Of-DOM-NODE",{ 
    "margin-top":"5px",
    "padding-left":"2px",
    "padding-right:"2px"
}); 

 

Summary


This comes in really handy when adjusting the position of elements on the page or when you need to change the style of an element when something happens. Using just a CSS file you can't do this. I think this is a great asset and not to mention it's very easy to do. Start combining this with dojo.coords, dojo.query and getClientId and you've got yourself a very powerful way of manipulating the style of DOM Nodes within an XPage or even pre-XPage web pages if you're willing to go the distance to include dojo support.
 
Visit keithstric.com for other Lotus Notes/Domino/XPage articles


expanded Article information
collapsed Article information
Category:
Designing XPage Applications
Tags:
Dojo, Javascript

This Version: Version 20 March 24, 2010 11:23:39 AM by Keith Strickland  

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (20)
collapsed Versions (20)
Version Comparison     
Version Date Changed by               Summary of changes
This version (20) Mar 24, 2010 11:23:39 AM Keith Strickland  
19 Mar 24, 2010 11:21:14 AM Keith Strickland  
18 Mar 24, 2010 11:20:35 AM Keith Strickland  
17 Mar 24, 2010 11:20:13 AM Keith Strickland  
16 Mar 24, 2010 11:19:44 AM Keith Strickland  
15 Mar 24, 2010 11:19:14 AM Keith Strickland  
14 Mar 24, 2010 11:18:52 AM Keith Strickland  
13 Mar 24, 2010 11:17:26 AM Keith Strickland  
12 Mar 24, 2010 11:16:31 AM Keith Strickland  
11 Mar 24, 2010 11:15:44 AM Keith Strickland  
10 Mar 24, 2010 11:14:46 AM Keith Strickland  
9 Mar 24, 2010 11:10:20 AM Keith Strickland  
8 Mar 24, 2010 11:09:58 AM Keith Strickland  
7 Mar 24, 2010 11:09:41 AM Keith Strickland  
6 Mar 24, 2010 11:09:10 AM Keith Strickland  
5 Mar 24, 2010 11:01:20 AM Keith Strickland  
4 Mar 24, 2010 11:00:43 AM Keith Strickland  
3 Mar 24, 2010 10:58:18 AM Keith Strickland  
2 Mar 24, 2010 10:57:32 AM Keith Strickland  
1 Mar 24, 2010 10:28:29 AM Keith Strickland  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use