更新代码
<div>
<button type="button" class="submit btn btn-default" id="btnSubmit">Submit
</button>
<button type="button">Cancel</button>
</div>
<script>
$("#btnSubmit").click(function(e)
{
e.preventDefault();
//btn Click validation and code submission goes here..
alert("Form has been successfully submitted");
window.open("http://....../viewmyrequest.aspx","_self");
}
</script>
window.location.href 仅在 Debug模式下工作,如果我关闭 Debug模式,则不会重定向到其他窗口。
我已经探索了许多具有相同主题的 StackOverflow 问题,但我没有对此问题得到任何可靠的答复。
window.location.href = "http://testwebsite.com/viewtickets.aspx"
我也尝试过其他选择
window.location = "http://testwebsite.com/viewtickets.aspx"
window.location.replace = "http://testwebsite.com/viewtickets.aspx"
最佳答案
试试这个。在我的所有网站中都可以跨浏览器工作。
loc = "http://testwebsite.com/viewtickets.aspx";
window.open(loc,'_self');
编辑: 这可能对你更有效..
<script>
function setURL(url){
document.getElementById('iframe').src = url;
}
</script>
<iframe id="iframe" src="idreesinc.com/research.html" />
<input type="button" onclick="setURL('URLHere')" />
它将把正确的 URL 插入 iframe 中。
关于javascript : window. location.href/window.open 在 iframe 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38211258/