...

View Full Version : increase size of alert



bbxrider
07-26-2009, 09:00 PM
for debugging, i create some alerts that can be sizeable. see attached for a sample of 1 that got truncated about 50% of total. is there someway to increase the size of the number of characters allowed in the alerts?
bob

Philip M
07-26-2009, 10:03 PM
There appears to be no limit to the number of charcaters in a normal Javascript alert. If you have created some kind of modal dialogue box, then you yourself have imposed the limit, possibly by limiting the size of the box.


Quizmaster: What three-letter word means "at this moment"?
Contestant: Then.

bbxrider
07-26-2009, 11:04 PM
i haven't created any modal dialog box
i'm simply using alert(variable)
the variable gets built by concatenating to it
is there a default max character size to a variable?
i've seen talk of 4096 but i'm not anywhere near that

rnd me
07-26-2009, 11:53 PM
is there a default max character size to a variable?
i've seen talk of 4096 but i'm not anywhere near that

no limit, though a variable name is limited to 64kb in most implementations.
i've loaded 50mb JSON files before, and it works, though it does take a little while.

Philip M
07-27-2009, 08:26 AM
i haven't created any modal dialog box
i'm simply using alert(variable)
the variable gets built by concatenating to itis there a default max character size to a variable?
i've seen talk of 4096 but i'm not anywhere near that

Check the concatenation syntax. (= instead of + ?)

bbxrider
07-27-2009, 09:17 AM
this is the code--
var msg1 = "";
for ( var i =0; i < f.length; i++) {
var e = f.elements[i];
var opt = e.optional;
msg1 += "for element " + i + " type= " + e.type + " name= " + e.name + " value= " + e.value + " optional= " + opt + " size= " + e.value.length + "\n";
}
alert(msg1);

the form has 60 elements, see the attachment in original post, the message box cuts off at element 22, if i start the loop at 23, i get the next 22 elements

Philip M
07-27-2009, 11:54 AM
What happens if you test with this:-

alert (f.length);
for ( var i =0; i < f.length; i++) {
var e = f.elements[i];
alert (e);
//var opt = e.optional;
//msg1 += "for element " + i + " type= " + e.type + " name= " + e.name + " value= " + e.value + " optional= " + opt + " size= " + e.value.length + "\n";
}

rnd me
07-27-2009, 01:07 PM
ok, i had an idea, (one of those things that only occur to you at 5am), and it seems to work pretty well.

tested firefox3.5:


function promptLimited(str, lineLimit){
lineLimit=lineLimit||20;
var rows=str.split("\n");
var pos=0;
var bod=rows.slice(pos, pos+lineLimit);
while(confirm(bod.join("\n")+"\n\n--- More? ---")){
pos+=lineLimit;
bod=rows.slice(pos, pos+lineLimit);
}
}

//firebug test:
promptLimited(document.body.innerHTML, 25); //25 line limit (defaults to 20 if not specified)



feel free to jazz it up with line numbers or range indicators (viewing lines 20-40)...

bbxrider
07-27-2009, 08:30 PM
thanks for thoughtful replies
for the phillpm suggestion, alert(e), see attached, got that 60x

for rnd_me, thanks for all that work, but i don't want to control how many items are displayed at once, i wanted to see them all, no matter how many, well within reason, like the 60 i have.

but wait, i have to apologize, i should have checked first but its different with different browsers, so somehow its browser based?
ie8=22ish
ff=all
chrome=23ish
safari=41ish (safari on windows)

so unless i find a 'production' need for the large display, i will just continue to debug in ff .

Philip M
07-28-2009, 09:02 AM
I think that the problem is not the size of the alert message, but the number of concatenations. IE has particular problems in this area, and gets slower and slower the longer your string is.

Try something like:-

var buffer = new Array();
buffer.push ("More stuff");
alert (buffer.join(""));



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum