By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,149 Members | 885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,149 IT Pros & Developers. It's quick & easy.

change style of cursor for textarea

P: 3
Hi Folks,
I have a issue trying to change the cursor of area image map in run time, no static code, no id and no name.

the possibilities i have tried is

Expand|Select|Wrap|Line Numbers
  1. document.getElementsByTagName("area").style.cursor=hand;
  2. var cur=document.getElementsByTagName("area");
  3. cur..style.cursor=hand;
not working
-----------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. function winload()
  2. {
  3.  
  4. var areatg=document.getElementsByTagName("AREA");
  5. for(k=0;k<areatg.length;k++)
  6. {
  7. areatg[k].setAttribute("href","#");
  8. }
  9. }
  10. window.onload=winload;
this is working only one time onload only.

tried with setTimeout, setInterval onmouseover.

not working
-------------------------------------------------------------

Please send me your valuable useful suggestions As soon as possible

Cheers,
Dinesh
Jan 18 '08 #1
Share this Question
Share on Google+
5 Replies


gits
Expert Mod 5K+
P: 5,333
hi ...

welcome to TSDN ...

first: please use a meaningful title for your thread and use code-tags when posting source-code ... read the posting guidelines

second: to your problem ... you could use the getElementsByTagName()-method but you should know, that this function returns a node-list (list of elements with the specified tagname) ... so you have to refer to the element with the correct index in the retrieved list. assuming you only have one textarea in your page you could use the following statement:

Expand|Select|Wrap|Line Numbers
  1. document.getElementsByTagName('textarea')[0].style.cursor = 'hand';
  2.  
kind regards
Jan 18 '08 #2

P: 3
Thanks for replying to my issue. As per your suggestion, I have tried this but not working, can think for better solution.

Expand|Select|Wrap|Line Numbers
  1. function changeLink()
  2. {
  3. var arealen=document.getElementsByTagName('area');
  4. for(i=0;i<arealen.length;i++)
  5. {
  6. document.getElementsByTagName('area')[i].style.cursor = 'hand';
  7. }
  8. }
  9.  
cheers,
dinesh
Jan 19 '08 #3

gits
Expert Mod 5K+
P: 5,333
Thanks for replying to my issue. As per your suggestion, I have tried this but not working, can think for better solution.

Expand|Select|Wrap|Line Numbers
  1. function changeLink()
  2. {
  3. var arealen=document.getElementsByTagName('area');
  4. for(i=0;i<arealen.length;i++)
  5. {
  6. document.getElementsByTagName('area')[i].style.cursor = 'hand';
  7. }
  8. }
  9.  
cheers,
dinesh
does that work? the tagName should be textarea ... isn't it? and it is a better idea to store the reference once you have retrieved the nodelist ... since all dom-methods are expensive in terms of runtime-performance ... so avoid it when possible:

Expand|Select|Wrap|Line Numbers
  1. function changeLink() {
  2.     var areas = document.getElementsByTagName('textarea');
  3.     var arealen = areas.length;
  4.  
  5.     for (i = 0; i < arealen; i++) {
  6.         areas[i].style.cursor = 'hand';
  7.     }
  8. }
kind regards

ps: in FF & mac i just tested the 'hand' cursor that didn't work while the 'pointer' cursor did :)
Jan 19 '08 #4

jerone
P: 2
I'm having the same issue today.
The topicstarter does mean area (used for image maps).
Expand|Select|Wrap|Line Numbers
  1. areas = document.getElementsByTagName('area');
  2. for(var a=0;a<areas.length; a++){
  3.     areas[a].style.cursor = "help";
  4. }
I've tested it in FF and it works, but it doesn't work in Opera and IE.
Anyone got another solution.

gr J
Apr 1 '08 #5

Expert 100+
P: 392
It is a better convention in JavaScript to use single quotes in JavaScript that double. How many area tags do you have in your page? Can you post the code from the page?
Apr 1 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.