Updated Code
<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 is working only on debug mode and redirect to other window is not happening if i turned off debug mode.
window.location.href仅在调试模式下工作,如果我关闭调试模式,则不会重定向到其他窗口。
i have explored many * questions with the same topic but i haven't got any solid response for this issue.
我已经使用相同的主题探索了许多*问题,但我没有对此问题做出任何可靠的回应。
window.location.href = "http://testwebsite.com/viewtickets.aspx"
i have tried for other options too
我也尝试过其他选择
window.location = "http://testwebsite.com/viewtickets.aspx"
window.location.replace = "http://testwebsite.com/viewtickets.aspx"
2 个解决方案
#1
0
I am 99% sure the issue is you are using a submit button and that is submitting the form which is not allowing your JavaScript to run. So either you need to set the type to be a button and not a submit button OR you need to cancel the click action.
我99%肯定问题是你正在使用提交按钮,并且提交的表单不允许你的JavaScript运行。因此,您需要将类型设置为按钮而不是提交按钮,或者您需要取消单击操作。
<button type="button" ... >
or
<button onclick="foo(); return false;" ... >
#2
0
Try this. Works cross browser in all my sites.
试试这个。在我的所有网站中跨浏览器工作。
loc = "http://testwebsite.com/viewtickets.aspx";
window.open(loc,'_self');
EDITED: This may work better for you..
编辑:这可能对你有用..
<script>
function setURL(url){
document.getElementById('iframe').src = url;
}
</script>
<iframe id="iframe" src="idreesinc.com/research.html" />
<input type="button" onclick="setURL('URLHere')" />
It will insert the correct URL into the iframe.
它会将正确的URL插入iframe。
#1
0
I am 99% sure the issue is you are using a submit button and that is submitting the form which is not allowing your JavaScript to run. So either you need to set the type to be a button and not a submit button OR you need to cancel the click action.
我99%肯定问题是你正在使用提交按钮,并且提交的表单不允许你的JavaScript运行。因此,您需要将类型设置为按钮而不是提交按钮,或者您需要取消单击操作。
<button type="button" ... >
or
<button onclick="foo(); return false;" ... >
#2
0
Try this. Works cross browser in all my sites.
试试这个。在我的所有网站中跨浏览器工作。
loc = "http://testwebsite.com/viewtickets.aspx";
window.open(loc,'_self');
EDITED: This may work better for you..
编辑:这可能对你有用..
<script>
function setURL(url){
document.getElementById('iframe').src = url;
}
</script>
<iframe id="iframe" src="idreesinc.com/research.html" />
<input type="button" onclick="setURL('URLHere')" />
It will insert the correct URL into the iframe.
它会将正确的URL插入iframe。