using function in href

admin

Administrator
Staff member
I have an href which calls a javascript function which sets the window.location.href to another page with parameters as shown below. This works fine when clicked on but if someone tries to open the link in a new window using the right click, they get a javascript error 'object expected'. How can I do it?

<a href=http://www.webdeveloper.com/forum/archive/index.php/"javascript:displayTrend('CurrentL1','CurrentL2','CurrentL3','','Current Trend')">Current</a>

and the function looks like this:

<script type="text/javascript">
function displayTrend(field1, field2, field3, title)
{
var href;
href = "../Trends/TrendPage.asp?field1=" + field1;
if (field2 != "")
href += "&field2=" + field2;
if (field3 != "")
href += "&field3=" + field3;
href += "&min=" + parent.frames['basic_main'].minRec;
href += "&max=" + parent.frames['basic_main'].maxRec;
href += "&back=../basic/HarmonicHistory_frames.htm" ;
href += "&title=" + title;
href += "&firsttime=1";

parent.location.href = href;
}
</script>
 
Top