?
Solved

max string length?

Posted on 1998-05-27
4
Medium Priority
?
646 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 100 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…
Suggested Courses

840 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