mgisonno
05-08-2006, 10:03 PM
So basically this code is throwing a 'syntax' error and I can't seem to figure out why. Obviosly I'm a novice javascripter, so go easy on me.
I have this in the head of the document:
<script language="JavaScript" type="text/javascript">
<!--
function button(url, color, text, width, height) {
if (target=="") {
document.write ("<div class='" + color + "button' onclick='javascript:window.location='" + url + "';' style='width: " + width + "px; height: " + height + "px;'><a href='" + url + "' class='buttonLink'>" + text + "</a></div>");
}
else if (target=="new") {
document.write ("<div class='" + color + "button' onclick='javascript:window.open('" + url + "'; return false;') style='width: " + width + "px;height: " + height + "px;'><a href='" + url + "' class='buttonLink' target='_blank'>" + text + "</a></div>");
}
}
// -->
</script>
And this in the body:
<script language="JavaScript1.2" type="text/javascript">
var target = "new";
button("http://www.urlgoeshere.com", "green", "button test", "300", "20");
</script>
I have this in the head of the document:
<script language="JavaScript" type="text/javascript">
<!--
function button(url, color, text, width, height) {
if (target=="") {
document.write ("<div class='" + color + "button' onclick='javascript:window.location='" + url + "';' style='width: " + width + "px; height: " + height + "px;'><a href='" + url + "' class='buttonLink'>" + text + "</a></div>");
}
else if (target=="new") {
document.write ("<div class='" + color + "button' onclick='javascript:window.open('" + url + "'; return false;') style='width: " + width + "px;height: " + height + "px;'><a href='" + url + "' class='buttonLink' target='_blank'>" + text + "</a></div>");
}
}
// -->
</script>
And this in the body:
<script language="JavaScript1.2" type="text/javascript">
var target = "new";
button("http://www.urlgoeshere.com", "green", "button test", "300", "20");
</script>