SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Aug 11, 2008, 21:06 #1
- Join Date
- Jul 2008
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
variable declarations in an array
hello,
just wondering if this could be changed from the following:
T1 = new Array("graphics/cursor/valentine1.gif",80,31,"graphics/cursor/valentine1.gif",80,31,
"graphics/cursor/valentine1.gif",80,31,"graphics/cursor/valentine1.gif",80,31,
"graphics/cursor/valentine1.gif",80,31,"graphics/cursor/valentine1.gif",80,31)
to a variable declaration: replace the "graphics/cursor/valentine1.gif", with a variable name: T1 = new Array("' + cursor-name + '",80,31).
to where instead of the cursor being "harded coded" it is a variable.
thanks,
john....
-
Aug 11, 2008, 22:11 #2
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:foo = 'cursor5' T1 = new Array("graphics/" + foo + "/valentine1.gif",80,31,
-
Aug 12, 2008, 03:47 #3
- Join Date
- Jul 2008
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Aug 12, 2008, 04:38 #4
- Join Date
- Aug 2007
- Location
- Brighton, UK
- Posts
- 2,006
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
BTW, There is no need to use "new Array" - It's better to use var array = [];
::
You can also mix and match as much as you like in arrays:
Code JavaScript:var name = 'Mickey Mouse'; var foo = 'hello' + ' ' + name; var array = [ foo, 1+2, 1000, 'a string', { prop1: 'value 1', prop2: 'value 2' }, ['a','b','c','d','e'] ];
★ James Padolsey
–––––––––––––––––––––––––––––––––––––––
Awesome JavaScript Zoomer (demo here)
'Ajaxy' - Ajax integration solution (demo here)
-
Aug 12, 2008, 05:09 #5
- Join Date
- Jul 2008
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hello all,
i have another queston, look at the CSS code below:
<style type="text/css"> body { cursor: url('graphics/cursor/romantic_1.cur'); } a {cursor: url('graphics/cursor/bible_1.cur');}</style>
the question is, is it possible to have variables in the above statement? like this:
<style type="text/css"> body { cursor: url(cursor1); } a {cursor: url(cursor2);}</style>
where the hard coded URL 'graphics/cursor/romantic_1.cur' is replaced with the variable name cursor1?
or is variables not allowed in CSS...
thanks,
john....
-
Aug 12, 2008, 05:34 #6
- Join Date
- Aug 2007
- Location
- Brighton, UK
- Posts
- 2,006
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You cannot place JavaScript vairables in CSS - but you can apply inline styles to an element using JavaScript:
Code JavaScript:element.style.cursor = 'url(' + cursor1 + ')';
★ James Padolsey
–––––––––––––––––––––––––––––––––––––––
Awesome JavaScript Zoomer (demo here)
'Ajaxy' - Ajax integration solution (demo here)
-
Aug 12, 2008, 16:04 #7
- Join Date
- Jul 2008
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Aug 12, 2008, 20:21 #8
- Join Date
- Jul 2008
- Posts
- 5,757
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
that is javascript.
element would be a DOM element.
Bookmarks