<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="./jquery.js"></script>
<style type="text/css">
.spades { color: blue; font-family: Arial, Verdana, Tahoma, sans-serif; font-size: 120%; font-weight:bold }
.hearts { color: red; font-family: Arial, Verdana, Tahoma, sans-serif; font-size: 120%; font-weight:bold }
.diams { color: #FF6600; font-family: Arial, Verdana, Tahoma, sans-serif; font-size: 120%; font-weight:bold }
.clubs { color: #009D00; font-family: Arial, Verdana, Tahoma, sans-serif; font-size: 120%}
</style>
</head>
<body onload="bid_done('2C','TESTSTRING')">
<table id="bidsdone" border="1">
<caption><b>Bids done:</b></caption>
<tr>
</tr>
</table>
TEST3
<div>
<p id="clu"><span class="clubs">♣</span></p>
<p id="dia"><span class="diams">♦</span></p>
<p id="hea"><span class="hearts">♥</span></p>
<p id="spa"><span class="spades">♠</span></p>
</div>
</body>
<script type="text/javascript">
function add_bid_done() {
var table=document.getElementById("bidsdone");
var row=table.insertRow(-1);
var cell1=row.insertCell(0);
}
function bid_done(x,bc) {
add_bid_done();
var bid_abbr = x;
var bidsdoneRows=1;
var bidsdoneCell=0;
var rows=document.getElementById("bidsdone").rows;
var rowCells=rows[bidsdoneRows].cells;
x=x.replace(/C/g,document.getElementById("clu").innerHTML);
x=x.replace(/D/g,document.getElementById("dia").innerHTML);
x=x.replace(/H/g,document.getElementById("hea").innerHTML);
x=x.replace(/S/g,document.getElementById("spa").innerHTML);
x=x.replace(/N/g,"NT");
rowCells[bidsdoneCell].innerHTML=x;
rowCells[bidsdoneCell].title=bc;
rowCells[bidsdoneCell].abbr=bid_abbr;
rowCells[bidsdoneCell].setAttribute('onclick', 'alert(title)');
}
</script>
</html>
Above code works in Firefox 10.0.4 but not in IE7. (This is only part of the code to show the issue that I have.)
I have two issues in IE7:
-
It displays “2<♠PANT class=clubs>♣♠PANT>” iso the Green Clubs character.
-
the onclick seems not to work.
Thanks,
Koen
As you are doing one replace after the other, the HTML code from one replace will be affected by the other replaces. As the
innerHTMLreturns different values in different browsers, the result differs.Some browsers return the HTML tags in uppercase, so when the
Ccharacter in'2C'is replaced by a SPAN tag in uppercase, the other replaces will replace theSandNin the string.Do all the replaces at once, then one replace won’t affect another:
You don’t have any
titlevariable, soalert(title)will fail. I suppose that you want to show the title of the element: