Forum Moderators: open
i am working in jsp application . in that i am calling a java script method onClick event of an image.
its working fine with Mozilla browser. but showing error in IE.
The code is as follows,
<td><a href ="javascript:return(true)" onclick="javascript:loadPlugins('<%=save%>')"><img src="../user/resources/images/btn_save.gif" border="0"></a></td>
<td><a href="javascript:retrun(true)" onclick="javascript:loadPlugins('<%=cancel%>')"><img src="../user/resources/images/btn_cancel.gif" border="0" ></a> </td>
the Javascript is as follows
function loadPlugins(act){
var action=act;
if (action=="SAVE"){
document.forms[0].action.value="SAVE";
if(parent.pluginFrame.document.forms[0].oldfamilyid.value){
parent.pluginFrame.document.forms[0].actions.value="SAVE";
parent.pluginFrame.document.forms[0].action="/sas/user/saveplugins.do";
parent.pluginFrame.document.forms[0].submit();
}else{
alert(" No Plugins are selected");
}
}else{
parent.pluginFrame.document.forms[0].actions.value="CANCEL";
parent.pluginFrame.document.forms[0].submit();
}
return ;
}
IE gives the following javascript error return is outside the function
can any one suggest a solution for this
i am sending the code again plz. go through it.
<td class="pluginfamily" ><a href="javascript:return( true)" onclick="javascript:loadPlugins(<%=id%>);" target="pluginFrame"><%=family.getName()%></a></td>
function loadPlugins(id){
if(parent.pluginFrame.document.forms[0].oldfamilyid.value){
parent.pluginFrame.document.forms[0].newfamilyid.value=id;
parent.pluginFrame.document.forms[0].submit();
}else{
parent.pluginFrame.document.forms[0].newfamilyid.value=id;
parent.pluginFrame.document.forms[0].submit();
}
return ;
}
I checked the javascript console of Mozilla its giving an error as follows.
Error: invalid return;
Source:javascript:return(true);
return(true)
even though its giving error in Mozilla browser the form is getting submitted and working fine. but the same thing is not working in IE . In IE its giving a javascript error retrun is out of the function.
I have used the javascript:return(true) method in some other jsp also. there also I am facing the same problem.
looking forward for a solution....
function loadPlugins(act){
var action=act;
if (action=="SAVE"){
document.forms[0].action.value="SAVE";
if(parent.pluginFrame.document.forms[0].oldfamilyid.value){
parent.pluginFrame.document.forms[0].actions.value="SAVE";
parent.pluginFrame.document.forms[0].action="/sas/user/saveplugins.do";
parent.pluginFrame.document.forms[0].submit();
}else{
alert(" No Plugins are selected");}
}
else{
parent.pluginFrame.document.forms[0].actions.value="CANCEL";
parent.pluginFrame.document.forms[0].submit();}
return ;
}
Shouldn't it be something like this, closing the action for the first "if" before the next one opens?
function loadPlugins(act){
var action=act;
if (action=="SAVE"){
document.forms[0].action.value="SAVE";}
if(parent.pluginFrame.document.forms[0].oldfamilyid.value){
parent.pluginFrame.document.forms[0].actions.value="SAVE";
parent.pluginFrame.document.forms[0].action="/sas/user/saveplugins.do";
parent.pluginFrame.document.forms[0].submit();
}else{
alert(" No Plugins are selected");}
else{
parent.pluginFrame.document.forms[0].actions.value="CANCEL";
parent.pluginFrame.document.forms[0].submit();}
return ;
}