Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with javascript, I think 2

Status
Not open for further replies.

piratefan

Programmer
Jul 20, 2003
195
US
<SCRIPT LANGUAGE=&quot;Javascript&quot;><!--
function banner() {} ; b = new banner() ; n = 0;

b[n++]= &quot;<A HREF=' target='_PARENT'><IMG SRC=' BORDER='2'></A>&quot;

b[n++]= &quot;<A HREF=' target='_PARENT'><IMG SRC=' BORDER='2'></A>&quot;

i=Math.floor(Math.random() * n) ;
document.write( b )
//--></SCRIPT>

I am trying to use the above code in a table cell. I recently switched my message board. This code worked fine on the old message board. For some reason, the banner is not showing up and I am getting a &quot;done, but with errors&quot; when the page loads. I feel pretty certain all my tags are closed correctly.
Those capital letters shouldn't matter should they? I mean in the anchor element.
Thanks.
 
IE 6 and the semicolons didn't change anything. Very confusing here. It is totally ignoring that cell with the javascript for the random banner.
Thanks.
 
piratefan,

This is really weird. The code you posted works fine for me in IE. Although correct, I can only suggest changing the line that reads:

Code:
function banner() {} ; b = new banner() ; n = 0;

to:

Code:
b = new Array() ; n = 0;

Might possibly make a difference in some browsers, possibly, but still has the same end result.

Sorry I can't be more help!

Dan
 
Tried that Dan. Didn't work. Is there a way to circumvent this code? It almost has to be the javascript and go figure.
 
Do you have a URL where we can see your version of the source?

I just can't understand why it's working for me... It's a very unlikely possibility, but it could be a server-side problem...

Dan
 
piratefan,

If you copy the code you posted into a fresh document as follows...

Code:
<html>
<head></head>
<body>
... paste in your code here ...
</body>
</html>

Then save it as something simple like test.html. Now try and load it on your browser. I know it may sound like I'm being a little pedantic here... but I read in your post:

Code:
<qoute>I hope I can do this okay.  I tried abbreviating the code some.  Shortened the anchor tags as best I could for simplicty.  The last table I apologize for because it is code that was already in place with my message board and I am afraid if I try to abbreviate that, I may look dumber than I am.</quote>

And I can't help but think that the error you are experiencing is caused by something else on the page. Or something in the code that you &quot;shortened&quot; before posting to us.

Please let us know how it goes...
Jeff
 
Thanks Jeff. The page is too long to copy entirely. I only &quot;abbreviate&quot; the code here after cutting and pasting. To save everyone looking at too much code. For example, I have 5 sponsors, not 2, but to save on the eyes, I just delete 3 of them after I cut and paste. Same for anchor tags. I have long identifiers with them and I just abbreviate them here so that they don't confuse the issue.
Once again, thanks.
 
piratefan,

Without a URL or your version of the source, I don't think that there's much more we can do for you.

Did you try Jeff's suggestion of copying what was pasted here in the forum and seeing if it errored?

Dan
 
Thanks for the help. The problem is that there is more code to the page, but too much to cut and paste. The message board here will only allow so much.

I am positive the javascript is good code. I am very new with this stuff. And I am wondering if there is a way to circumvent the javascript code? Like I say, I know little about scripting languages, but maybe something else would work. I am just taking stabs at this.

Thanks again.
 
If change you script definition from:

Code:
<SCRIPT LANGUAGE=&quot;Javascript&quot;>

to:

Code:
<SCRIPT LANGUAGE=&quot;XJavascript&quot;>

Then that will prevent the browser from running any of the Javascript in that definition block.

Then you can maybe help narrow down where else on the page the error is being caused.

Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top