问题描述:模态对话框中有保存操作,提交方式为location.href
问题现象:点击保存,总是打开新的页面
解决过程:用网上说的在<head></head>中添加<base target="_self" /> 但是仍然会弹出新页面。
解决方法:在对话框中不能用location.href,会打开新页面。可以用<a></a>标签模拟点击事件,具体如下:
在<head></head>中添加<base target="_self" />
在body中增加隐藏的<a>:<a id='save' href='' style='display:none'></a>
js为href赋值并触发点击:document.getElementById("save").href="********************“;
document.getElementById("save").click();
好了,问题成功解决了!