/    Sign up×
Community /Pin to ProfileBookmark

Javascript code not working in IE8!

hey guys,

im having trouble with some javascript code in one of my homework assignments. The code works fine in other browsers except internet explorer 8. The javascript is a email scrambler so email harvesters can’t steal the emails. The code is split up between two files. Most of the code is in my html file and part is inside the spam.js file.

The weird thing is this code works in firefox, chrome, safari and opera. But not internet explorer 8. I haven’t tested the code in older versions of IE, but im guessing that it wont work there either.

[code=html]
<?xml version=”1.0″ encoding=”UTF-8″ ?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<title>Monroe Public Library</title>
<link href=”mplstyles.css” rel=”stylesheet” type=”text/css” />
<script type=”application/javascript” src=”spam.js”></script>

<script type=”text/javascript”>

function showEM(userName, emServer) {

/*
The showEM() function displays a link to the user’s
email address.
The text of the user and e-mail server names are entered in
reverse order to thwart e-mail harversters.
*/

userName = stringReverse(userName); // reverse the text of the userName paramater
emServer = stringReverse(emServer); // reverse the text of the emServer paramater

var emLink = userName + “@” + emServer; // combine the text of userName and emServer
document.write(“<a href=’mailto:” + emLink + “‘>”);
document.write(emLink);
document.write(“</a>”);
}

</script>
</head>

<body>
<div id=”pageContent”>

<div id=”head”><img src=”mpl.jpg” alt=”Monroe Public Library” /></div>

<div id=”links”>
<span>Quick Links</span>
<a href=”#”>Home Page</a>
<a href=”#”>Online Catalog</a>
<a href=”#”>Friends of MPL</a>
<a href=”#”>New Books and Other Good Reading</a>
<a href=”#”>Ohio Virtual Library</a>
<a href=”#”>Internet Public Library</a>
<a href=”#”>Services and Collection</a>
<a href=”#”>Adult Programs</a>
<a href=”#”>Teen Central</a>
<a href=”#”>Children’s Room</a>
<a href=”#”>Computers at MPL</a>
<a href=”#”>Computer Rules and Procedures</a>
<a href=”#”>Staff Directory</a>
<a href=”#”>Library Records</a>
</div>

<div id=”main”>
<h2>Staff Directory</h2>

<table border=”1″ cellpadding=”5″ cellspacing=”0″>
<tr>
<th>Name</th>
<th>Phone</th>
<th>E-Mail</th>
</tr>

<tr>
<td>Catherine Adler<br />Library Director</td>
<td>555-3100</td>
<td>
<script type=”text/javascript”>
showEM(“reldac”, “vog.lpm”);
</script>
</td>
</tr>
<tr>
<td>Michael Li<br />Head of Adult Services</td>
<td>555-3145</td>
<td>
<script type=”text/javascript”>
showEM(“ilekim”, “vog.lpm”);
</script>
</td>
</tr>
<tr>
<td>Kate Howard<br />Head of Technical Services</td>
<td>555-4389</td>
<td>
<script type=”text/javascript”>
showEM(“drawohk”, “vog.lpm”);
</script>
</td>
</tr>
<tr>
<td>Robert Hope<br />Head of Children’s Services</td>
<td>555-7811</td>
<td>
<script type=”text/javascript”>
showEM(“epohr”, “vog.lpm”);
</script>
</td>
</tr>
<tr>
<td>Wayne Lewis<br />Circulation Services Supervisor</td>
<td>555-9001</td>
<td>
<script type=”text/javascript”>
showEM(“siwelw”, “vog.lpm”);
</script>
</td>
</tr>
<tr>
<td>Bill Forth<br />Interlibrary Loan</td>
<td>555-9391</td>
<td>
<script type=”text/javascript”>
showEM(“htrofb”, “vog.lpm”);
</script>
</td>
</tr>
</table>
</div>

<address>
<b>Monroe Public Library</b>
580 Main Street, Monroe, OH &nbsp;&nbsp;45050
<b>Phone</b>(513) 555-0211
<b>Fax</b>(513) 555-0241
</address>

</div>

</body>
</html>
[/code]

spam.js code:

[CODE]
function stringReverse(textString) {
if (!textString) return ”;
var revString=”;
for (i = textString.length-1; i>=0; i–)
revString+=textString.charAt(i)
return revString;
}
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@cluefulJan 11.2011 — [CODE]<script type="application/javascript" src="spam.js"></script>[/CODE][/QUOTE]That was supposed to succeed:
[CODE]<script type="text/javascript" src="spam.js"></script>[/CODE]but I.E. doesn't want to recognise it, so it can never be used.
Copy linkTweet thisAlerts:
@janusmccarthyJan 11.2011 — What clueful said, but perhaps a little clearer:

The mime type for javascript is application/javascript, but because IE doesn't support it, and all browsers at least recognize text/javascript, so we use it, even though its obsolete.

So just add the text/javascript definition for your spam.js
[CODE]
<script type="text/javascript" src="spam.js"></script>
[/CODE]
×

Success!

Help @emiljan 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 5.30,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...