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

Why doesn't javascript work when id attribute uses hyphen?

P: 1
My HTML calls a JavaScript on-click to open a new window. My id attribute doesn't work when I use a hyphen but it does work when I replace it with an underscore.

Expand|Select|Wrap|Line Numbers
  1.    <script language="JavaScript" type="text/javascript" src="multiple.js">
  2.     function newWin(url,w,h) {  var day= new Date();  var id = day.getTime();  var ww = w+750;  var wh = h+125;  if ((screen.height) && (wh > screen.height-100)) { wh = screen.height-100; }  var params = 'width='+ww+',height='+wh+',scrollbars,resizable';  var win = open(url,id,params)} 
  4.     // -->
  5.     </script>
  6. ....
  7. <td>
  8. <a href="" class="newWin" id="2010_annual"><img src="" height="140" width="100"  /></a>
  9. </td>
Feb 16 '11 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 7,435
It's probably treating the hyphen as 'subtract' instead of a hyphen.
Feb 16 '11 #2

Post your reply

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