
Bug: encodeURIComponent() in bookmarklet chops off text
Create a bookmarklet like this:
javascript:d=window.encodeURIComponent(getSelection());alert(d);
Select several paragraphs of text and run. You will see that the encoded text is incomplete. It truncates (chops off) at 200 characters or so. The same bookmarklet runs fine in Opera. After several tests, the problem doesn't seem to be with getSelection() which works fine. So it must be in encodeURIComponent().
There is no documented length restriction on encodeURIComponent, and the URL bar allows URLs that are tens of thousands of characters long so there should be no restriction on encodeURIComponent length.
Thank you -- Mark
Chosen solution
I tested on a block of text 4294 characters long. In Firefox 28, the alert box was missing the vertical scroll bar. I had to click inside the text and use the mouse wheel or the arrow keys to scroll. In Firefox 31, the vertical scroll bar showed correctly. Either way, the text wasn't truncated.
Read this answer in context 👍 2All Replies (3)
Chosen Solution
I tested on a block of text 4294 characters long. In Firefox 28, the alert box was missing the vertical scroll bar. I had to click inside the text and use the mouse wheel or the arrow keys to scroll. In Firefox 31, the vertical scroll bar showed correctly. Either way, the text wasn't truncated.
Start Firefox in Safe Mode to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
- Do NOT click the Reset button on the Safe Mode start window.
Thanks for the replies. I see that the format of the alert dialog mislead me. The overall problem is that a bookmarklet is not running correctly, but apparently the encodeURIComponent is working fine. I'll continue to research other avenues.
Thank you Mark