Solved

max string length?

Posted on 1998-05-27
4
641 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

730 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