Javascript Function - Parameter Length
I am calling a javascript function from hyperlink as shown below. Do this In this case the r
Solution 1:
Instead of embedding the javascript right in the href attribute, you could attach it dynamically.
Ex:
<a id="example_link">Do this</a>
Then:
document.getElementById('example_link').onclick = function(){
redirect('param1','param2','http://google.com');
return false;
};
If you're using a JavaScript library like jQuery, or if you have a better way of identifying the anchors than by ID, there are better solutions.
Solution 2:
Instead of using javascript:redirect, I would dynamically change the href of the a tag. This allows browser to use the "Open Link in new tab", Ctrl-click or similar functionality and probably wouldn't have the problem you are mentioning. This also lets the user see where they are going when they hover over the link.
Post a Comment for "Javascript Function - Parameter Length"