homepage Welcome to WebmasterWorld Guest from 54.205.52.110
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
IE & JavaScript Overload
How many js calls can you use?
DavidT




msg:613301
 3:28 pm on May 20, 2004 (gmt 0)

How much javascript can you stuff in without it causing display problems? So far, in one cell, I can get two. Add another and none of it will display. Mozilla browsers don't seem to be affected.

I have first a call to the axs tracking script, then a call to phpadsnew. I would like to have another phpadsnew slot beneath the former.

I understand it's not a good idea to use too much js, I am just trying to make my ad management less of a time-consuming chore.

 

BlobFisk




msg:613302
 3:52 pm on May 20, 2004 (gmt 0)

Hi DavidT,

I'm a little confused, what do you mean by display problems?

A lot of JS will impact your page size, but unless the JS is doing something visually, it should have no effect...

DavidT




msg:613303
 4:18 pm on May 20, 2004 (gmt 0)

Well I have this problem with every site I make, it may be the layout I use. I mean that when there are 'too many' js calls, sometimes it only takes two, in IE 5 when I preview all of the page content beneath the js will not display and you get the little yellow error symbol lower left. If i take out one of the js calls all returns to normal. Html comments also cause a similar problem.

BlobFisk




msg:613304
 4:28 pm on May 20, 2004 (gmt 0)

Looks like an error in one the javascript function that you remove to fix the problem.

If you double click on the JS error flag (the yellow alert in the bottom left corner) you will get the JS Error console - what does it say?

DavidT




msg:613305
 5:11 pm on May 20, 2004 (gmt 0)

It says:
Line: 309
Char: 1
Error: Syntax error
Code: 0
URL: my-local-file

Thanks for your help.

BlobFisk




msg:613306
 5:12 pm on May 20, 2004 (gmt 0)

What is line 309 in your local file? (It's generally not exact, so the script line close to that).

Mozilla has a better JS debugger that may be worth using...

txbakers




msg:613307
 5:14 pm on May 20, 2004 (gmt 0)

the problem is in your code somewhere. You'll need to fine tooth comb through your scripts and see what is causing the error.

Toss in "alert" every step of the way so you can see what you are actually getting for values, versus what you think you are getting.

As far as I know there is no limit to the amount of javascript on a page.

I have some pages where the javascript is actually more code than the HTML!

DavidT




msg:613308
 5:35 pm on May 20, 2004 (gmt 0)

Line 309 is where the third js call starts.

The actual scripts should be okay, they are from Google adsense or phpadsnew or axs. I'll keep playing around.

DavidT




msg:613309
 5:26 pm on May 28, 2004 (gmt 0)

Weeell I did keep playing around and the problem resolves itself if I remove, from the second instance of phpadsnew code, <!-- //--> which encloses the phpadsnew code or the body of it. I've had this problem before, comments preventing the page content from displaying when there is js on the page.

Does this make sense to anyone? I'm using I.E. 5.01. And secondly are the comments at all necessary for the scripts to function? In there ordinary state the whole bit is:


<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random = phpAds_random.substring(2,11);

document.write ("<" + "script language='JavaScript' type='text/javascript' src='");
document.write ("http://www.mysite.com/phpadsnew/adjs.php?n=" + phpAds_random);
document.write ("&amp;clientid=1");
document.write ("&amp;exclude=" + document.phpAds_used);
if (document.referer)
document.write ("&amp;referer=" + escape(document.referer));
document.write ("'><" + "/script>");
//-->
</script><noscript><a href='http://www.mysite.com/phpadsnew/adclick.php?n=abdead03'><img src='http://www.mysite.com/phpadsnew/adview.php?clientid=1&amp;n=klsdk00' border='0' alt=''></a></noscript>

I remove <!-- and //-->

Thanks.

BlobFisk




msg:613310
 10:28 am on May 29, 2004 (gmt 0)

You shouldn't really use
<!-- and --> in JS code. These are HTML comment tags.

This technique was used in the past to hide scripts from browsers that didn't understand JS, but that is (more or less) not an issue these days.

HTH

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved