/    Sign up×
Community /Pin to ProfileBookmark

simple js doesn’t work with IE7 (work with FF1.5)

Hi,
With IE7, the following code doesn’t add the table to the page when button is clicked.
the code is also uploaded to [url]http://startupisrael.com/gpazi/triptouch/test.php[/url]

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd“>
<html>

<head>
</head>
<body>
<script language=”Javascript” type=”text/javascript”>
function func()
{
var mydiv = document.getElementById(“mydiv”);

var mytable = document.createElement(“table”);
var mytr = document.createElement(“tr”);
var mytd = document.createElement(“td”);
var mytext = document.createTextNode(“this is my text”);
mytd.appendChild(mytext);
mytr.appendChild(mytd);
mytable.appendChild(mytr);
mydiv.appendChild(mytable);
}

</script>

<div id=”mydiv”><button onclick=”func();”>click</button></div>
</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJun 10.2007 — IE requires a tbody element to insert a table using the DOM
Copy linkTweet thisAlerts:
@gpaziauthorJun 10.2007 — It solved the problem.

Thank you
×

Success!

Help @gpazi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...