admin管理员组文章数量:1404329
I have 2 buttons Submit, which posts the data and gets back validation errors from the server, and a Cancel which calls window.history.back()
.
I click Submit X number of times (post es/stays on the page because of validation errors from server)
On Chrome I need to click Cancel X times to go back to the previous page.
On Mozilla I only need to click Cancel once.
I guess Chrome counts the POST requests/direct backs in the history but Mozilla does not. I am not familiar with how that works or jquery. Is there something I can do to fix this?
EDIT: Going to hard code the urls in the link as suggested. Will e back later to try and see if I can do this by sending the referring page url to the edit form to load into the Cancel button, if no one beats me to it.
…
{{ Form::submit('Create', array('class'=>'btn btn-info')) }}
<a href="{{ URL::previous() }}" class="back btn btn-danger">Cancel</a>
{{ Form::close() }}
<script type="text/javascript">
$(document).ready(function() {
$('a.back').click(function(e) {
e.preventDefault();
window.history.back();
return false;
});
});
…
</script>
I have 2 buttons Submit, which posts the data and gets back validation errors from the server, and a Cancel which calls window.history.back()
.
I click Submit X number of times (post es/stays on the page because of validation errors from server)
On Chrome I need to click Cancel X times to go back to the previous page.
On Mozilla I only need to click Cancel once.
I guess Chrome counts the POST requests/direct backs in the history but Mozilla does not. I am not familiar with how that works or jquery. Is there something I can do to fix this?
EDIT: Going to hard code the urls in the link as suggested. Will e back later to try and see if I can do this by sending the referring page url to the edit form to load into the Cancel button, if no one beats me to it.
…
{{ Form::submit('Create', array('class'=>'btn btn-info')) }}
<a href="{{ URL::previous() }}" class="back btn btn-danger">Cancel</a>
{{ Form::close() }}
<script type="text/javascript">
$(document).ready(function() {
$('a.back').click(function(e) {
e.preventDefault();
window.history.back();
return false;
});
});
…
</script>
Share
Improve this question
edited Dec 31, 2014 at 15:19
Howard Renollet
4,7392 gold badges25 silver badges31 bronze badges
asked Dec 30, 2014 at 20:53
PhilPhil
2,24611 gold badges36 silver badges58 bronze badges
3
- If you don't care about preserving the data why don't you just redirect wherever you want the user to go upon canceling? – Hanlet Escaño Commented Dec 30, 2014 at 21:28
- At the start of the day, I was convinced that I would need to call the edit form from different places... but now I think I don't so! Thanks! – Phil Commented Dec 30, 2014 at 21:35
-
I've never used it myself, but you may be able to use
return Redirect::back()
to return the user to where ever it was that they came from. – user1669496 Commented Dec 30, 2014 at 21:55
1 Answer
Reset to default 5In case you ever need to use back again, the safe cross-browser option was to use history.go(-1);
本文标签: javascriptwindowhistoryback() not working right in Chromeworks in MozillaStack Overflow
版权声明:本文标题:javascript - window.history.back() not working right in Chrome, works in Mozilla - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744800157a2625813.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论