Click to See Complete Forum and Search --> : Uggh! expected ")"


elwell
08-11-2003, 12:09 PM
I have 4 errors on my script for custom alerts and their all on different lines but their all the same error: expected ")" .
line : character
29, 87
49, 60
52, 42
53, 44

This is my script:






<html><head><title>Custom Alerts</title>
<script type="text/javascript">
<!--
function customAlert(alerttype, title, msg)
{
var icon
if (alerttype == "error")
icon = "skater.gif";
else if (alerttype == "info")
icon = "kickflip1.gif";
else
icon = "kickflip2.gif";

if (window.navigator.appName == "Microsoft Internet Explorer")
newalert = window.open("", "alertwindow", "width=300, height=150,modal=yes");
else
newalert = window.open("", "alertwindow", "width=300, height=150,");



newalert.document.writeln('<html>');
newalert.document.writeln('<head>');
newalert.document.writeln('<title>'+title+'</title>');
newalert.document.writeln('</head>');
newalert.document.writeln('<body bgcolor="#CCCCCC" onblur="self.focus()">');
newalert.document.writeln('<table cellpadding="10">');
newalert.document.writeln('<tr>');
newalert.document.writeln('<td width="50">');
newalert.document.writeln('<img src='+icon+' width="50" height="50" border="0" alt="['alerttype']" align="left" />');
newalert.document.writeln('</td>');
newalert.document.writeln('<td width="150">');
newalert.document.writeln(msg);
newalert.document.writeln('</td></tr>');
newalert.document.writeln('<tr><td align="center" colspan="2"><form>');
newalert.document.writeln('<input type="button" value="&nbsp;&nbsp; OK &nbsp;&nbsp;" onclick="window.close()" />');
newalert.document.writeln('</form></td></tr></table>');
newalert.document.writeln('</body></html>');

newalert.focus();

}
//-->
</script>
</head>
<body bgcolor="#CCCCCC">

<form>

<input type="button" value="Error" onClick="customAlert('error','You slammed Hard!', 'You just bailed!';)" />


<input type="button" value="Bails" onClick="customAlert('warn','Bails', 'Bails Hurt!';)" />
<input type="button" value="Info" onClick="customAlert('info','New SkatePark', 'There's a new skatepark in philly';)" />

</form>
</body>
</html>

AdamBrill
08-11-2003, 12:44 PM
Those errors mean you need to add a ')'. ;)

Try this:<html><head><title>Custom Alerts</title>
<script type="text/javascript">
<!--
function customAlert(alerttype, title, msg)
{
var icon
if (alerttype == "error")
icon = "skater.gif";
else if (alerttype == "info")
icon = "kickflip1.gif";
else
icon = "kickflip2.gif";

if (window.navigator.appName == "Microsoft Internet Explorer")
newalert = window.open("", "alertwindow", "width=300, height=150,modal=yes");
else
newalert = window.open("", "alertwindow", "width=300, height=150,");



newalert.document.writeln('<html>');
newalert.document.writeln('<head>');
newalert.document.writeln('<title>'+title+'</title>');
newalert.document.writeln('</head>');
newalert.document.writeln('<body bgcolor="#CCCCCC" onblur="self.focus()">');
newalert.document.writeln('<table cellpadding="10">');
newalert.document.writeln('<tr>');
newalert.document.writeln('<td width="50">');
newalert.document.writeln('<img src='+icon+' width="50" height="50" border="0" alt="[\'alerttype\']" align="left" />');
newalert.document.writeln('</td>');
newalert.document.writeln('<td width="150">');
newalert.document.writeln(msg);
newalert.document.writeln('</td></tr>');
newalert.document.writeln('<tr><td align="center" colspan="2"><form>');
newalert.document.writeln('<input type="button" value=" OK " onclick="window.close()" />');
newalert.document.writeln('</form></td></tr></table>');
newalert.document.writeln('</body></html>');

newalert.focus();

}
//-->
</script>
</head>
<body bgcolor="#CCCCCC">

<form>

<input type="button" value="Error" onClick="customAlert('error','You slammed Hard!', 'You just bailed!')" />

<input type="button" value="Bails" onClick="customAlert('warn','Bails', 'Bails Hurt!')" />

<input type="button" value="Info" onClick="customAlert('info','New SkatePark', 'There\'s a new skatepark in philly')" />

</form>
</body>
</html>

pyro
08-11-2003, 12:49 PM
There are also a few other errors with it... Try this:

<html><head><title>Custom Alerts</title>
<script type="text/javascript">
<!--
function customAlert(alerttype, title, msg)
{
var icon = "";
if (alerttype == "error") {
icon = "skater.gif";
}
else if (alerttype == "info") {
icon = "kickflip1.gif";
}
else {
icon = "kickflip2.gif";
}

if (window.navigator.appName == "Microsoft Internet Explorer") {
newalert = window.open("", "alertwindow", "width=300, height=150,modal=yes");
}
else {
newalert = window.open("", "alertwindow", "width=300, height=150,");
}

newalert.document.writeln('<html>');
newalert.document.writeln('<head>');
newalert.document.writeln('<title>'+title+'</title>');
newalert.document.writeln('</head>');
newalert.document.writeln('<body bgcolor="#CCCCCC" onblur="self.focus()">');
newalert.document.writeln('<table cellpadding="10">');
newalert.document.writeln('<tr>');
newalert.document.writeln('<td width="50">');
newalert.document.writeln('<img src='+icon+' width="50" height="50" border="0" alt="['+alerttype+']" align="left" />');
newalert.document.writeln('</td>');
newalert.document.writeln('<td width="150">');
newalert.document.writeln(msg);
newalert.document.writeln('</td></tr>');
newalert.document.writeln('<tr><td align="center" colspan="2"><form>');
newalert.document.writeln('<input type="button" value=" OK " onclick="window.close()" />');
newalert.document.writeln('</form></td></tr></table>');
newalert.document.writeln('</body></html>');

newalert.focus();

}
//-->
</script>
</head>
<body bgcolor="#CCCCCC">

<form>

<input type="button" value="Error" onClick="customAlert('error','You slammed Hard!', 'You just bailed!')" />

<input type="button" value="Bails" onClick="customAlert('warn','Bails', 'Bails Hurt!')" />

<input type="button" value="Info" onClick="customAlert('info','New SkatePark', 'There\'s a new skatepark in philly')" />

</form>
</body>
</html>