Solved

max string length?

Posted on 1998-05-27
4
637 Views
Last Modified: 2008-02-01
i'm trying to put a string literal whose length is over 280,000 bytes into a javascript string variable.  when i load the page into netscape the disk spins a really long time, and i end up killing the netscape session.  i'm running netscape 4.05 on SGI IRIX 6.3.   so, is there a maximum string length?  is there a way to work around this?
0
Comment
Question by:clemwang
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1279347
I read somewhere recently that Javascript has a string limitation of 255 characters although I can't find the documentation at the moment.  It certainly will not take a string of 280,000 bytes (which is 280,000 characters AFAIK).  You could split the string up into smaller chunks but this will give you a lot of small strings and may not be a viable option.  You would then need to rebuild at the point where you use them something like:

(assuming you want to write it to the screen)
document.write(string(1)+string(2)+string(3)......+string(n));

Looking at the line above you could probably write a for..loop to go through all the strings you have.  Possibly even store al the string names in an array.

Trevor.


0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 50 total points
ID: 1279348
I have never tried 280.000 bytes but whenever I need a big string, I build it like this - seems to work on quite big strings, definitely more than 256 bytes ;-):

var BigString = 'First part of a really big string';
    BigString += 'Next part of a really big string';
    BigString += 'Next part of a really big string';
....
0
 
LVL 5

Expert Comment

by:Trevor013097
ID: 1279349
Michel,

Isn't that method going to give you one string at the end though of 280,000 bytes?

Trevor.


0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1279350
Yes, but it seems Netscape can handle this a lot bettter than
var BigString = 'a huge number of bytes in one go.................................';

I have used the above example to generate complete listings of several tens of thousands of bytes - Not 280.000 I admit, but let's see what clemwang replies

Michel
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now