2
<a href="javascript:change('page_details_1','time,restime\n1387519869249,1196\n1387519906965,1368\n........')><img src="expand.jpg" alt="expand/collapse" id="page_details_1_image"></a>

in href i am calling a javascript function "change". The second parameter "\n1387519869249,1196\n1387519906965,1368\n...." is a very long value about 5070 characters.but at 5052 characters the link works.

Is there a limit to number of characters that can pass through href? the data is used to generate trend graph . If there is such a limitation what would be the best way to pass such info to javascript function?

kumar
  • 8,207
  • 20
  • 85
  • 176

4 Answers4

1

Try

<a href="javascript:void(0);" onclick="change('page_details_1','time,restime\n......'); return false;"><img src="expand.jpg" alt="expand/collapse" id="page_details_1_image"></a>

This way your URL isn't overly long.

SilverlightFox
  • 32,436
  • 11
  • 76
  • 145
0

The maximum limit of an href link is 2000: https://stackoverflow.com/a/417184/2413722.

If it's just data that you are wanting to send, then add a data attribute and get JavaScript to read that value (this is simplified somewhat in jQuery).

Community
  • 1
  • 1
Enijar
  • 6,387
  • 9
  • 44
  • 73
0

Here's a great article on passing data with JSON. I'm using PHP and it's much easier than I thought :) http://betterexplained.com/articles/using-json-to-exchange-data/

sinrise
  • 391
  • 3
  • 21
0

Why not save the long term into a variable

value = "yes";
<a href="javascript:alert(value)">blubb</a>
John
  • 760
  • 5
  • 12