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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Maria Carlson
    New Member
    • Feb 2011
    • 1

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

    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.

    Code:
       <script language="JavaScript" type="text/javascript" src="multiple.js">
        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)} 
    
        // -->
        </script>
    ....
    <td>
    <a href="http://bytes.com/submit/filename.pdf" class="newWin" id="2010_annual"><img src="http://bytes.com/submit/filename.jpg" height="140" width="100"  /></a>
    </td>
  • drhowarddrfine
    Recognized Expert Expert
    • Sep 2006
    • 7434

    #2
    It's probably treating the hyphen as 'subtract' instead of a hyphen.

    Comment

    Working...