views:

47

answers:

1

This jQuery statement works in recent versions of Firefox and Chrome but throws an error in IE 8.

left_bar_string = "<tr><td><a href='#' onclick= "return newPopUpWindow('somelink','window', '1000','800','100','0','yes')">Directions</a></td></tr>";

$("#side_bar").append(left_bar_string);

I think problem is with double quotes. Any comments/solutions?

A: 

This is a good example of why you should use DOM manipulation rather than innerHTML for this kind of thing:

var tr = $("<tr>");
var td = $("<td>").appendTo(tr);
$("<a>").text("Directions").attr("href", "#")
  .attr("onclick", "return newPopUpWindow('somelink','window', '1000','800','100','0','yes')")
  .appendTo(td);
$("#side_bar").append(tr);

Basically everything will be correctly escaped for you.

cletus