
Originally Posted by
wkenny
When I run it as pasted here it shows the table in the browser. But if I uncomment a second line in the first part of the 'If' clause I get a blank screen. [...]
<table>
<tr>
<script language="JavaScript">
Don't use the language attribute. Use the type attribute instead:
HTML Code:
<script type="text/javascript">
I won't quote the rest of your code for brevity, but as far as the interpreter is concerned, it's equivalent to:
Code:
if(-1 != path.indexOf('build')) {
document.write(...);
}
document.write(...);
...
document.write(...);
else {
document.write(...);
}
document.write(...);
...
document.write(...);
In other words, very broken and the else clause is a syntax error as it doesn't have an accompanying if statement.
To do what you're attempting, you must include block statements:
Code:
if(-1 != path.indexOf('build')) {
document.write(...);
...
document.write(...);
} else {
document.write(...);
...
document.write(...);
}
For maintenance purposes, I recommend that you always use block statements as it saves effort should a single statement after a control structure become many.
Mike
Bookmarks