setTimeout function not working on firefox
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am trying to use
<input type="submit" name="add" class="buy" onClick="setTimeout('history.go(0);',2000);"/>
It reloads the page on click after two seconds in chrome but it doesnt work in Firefox.
I went through this Why does window.location.reload need setTimeout to work in firefox. It still didn't work for me. Please help me find a way I can achieve my required functionality accross both browsers.
javascript cross-browser
add a comment |
I am trying to use
<input type="submit" name="add" class="buy" onClick="setTimeout('history.go(0);',2000);"/>
It reloads the page on click after two seconds in chrome but it doesnt work in Firefox.
I went through this Why does window.location.reload need setTimeout to work in firefox. It still didn't work for me. Please help me find a way I can achieve my required functionality accross both browsers.
javascript cross-browser
3
While a string of code is a valid parameter tosetTimeout
, it is fraught with the same issues thateval
has. Why not pass a function that callshistory.go(0)
instead?
– chazsolo
Nov 23 '18 at 17:33
@chazsolo I tried history.go(0) but it doesn't refresh all the fields on the page in the chrome and doesn't work in Firefox.
– Navroop
Nov 23 '18 at 17:40
You triedsetTimeout(function() { history.go(0); }, 2000);
? Can you provide an MCVE to help us understand?
– chazsolo
Nov 23 '18 at 17:45
@chazsolo on the page which I want to refresh on click has fields like height width counter_number which are supposed to be zero on refresh. All these field refresh when I click the button in chrome but this onclick function doesnt work in firefox.
– Navroop
Nov 23 '18 at 17:55
add a comment |
I am trying to use
<input type="submit" name="add" class="buy" onClick="setTimeout('history.go(0);',2000);"/>
It reloads the page on click after two seconds in chrome but it doesnt work in Firefox.
I went through this Why does window.location.reload need setTimeout to work in firefox. It still didn't work for me. Please help me find a way I can achieve my required functionality accross both browsers.
javascript cross-browser
I am trying to use
<input type="submit" name="add" class="buy" onClick="setTimeout('history.go(0);',2000);"/>
It reloads the page on click after two seconds in chrome but it doesnt work in Firefox.
I went through this Why does window.location.reload need setTimeout to work in firefox. It still didn't work for me. Please help me find a way I can achieve my required functionality accross both browsers.
javascript cross-browser
javascript cross-browser
edited Nov 23 '18 at 17:51
dince12
1,4431721
1,4431721
asked Nov 23 '18 at 17:30
Navroop Navroop
468
468
3
While a string of code is a valid parameter tosetTimeout
, it is fraught with the same issues thateval
has. Why not pass a function that callshistory.go(0)
instead?
– chazsolo
Nov 23 '18 at 17:33
@chazsolo I tried history.go(0) but it doesn't refresh all the fields on the page in the chrome and doesn't work in Firefox.
– Navroop
Nov 23 '18 at 17:40
You triedsetTimeout(function() { history.go(0); }, 2000);
? Can you provide an MCVE to help us understand?
– chazsolo
Nov 23 '18 at 17:45
@chazsolo on the page which I want to refresh on click has fields like height width counter_number which are supposed to be zero on refresh. All these field refresh when I click the button in chrome but this onclick function doesnt work in firefox.
– Navroop
Nov 23 '18 at 17:55
add a comment |
3
While a string of code is a valid parameter tosetTimeout
, it is fraught with the same issues thateval
has. Why not pass a function that callshistory.go(0)
instead?
– chazsolo
Nov 23 '18 at 17:33
@chazsolo I tried history.go(0) but it doesn't refresh all the fields on the page in the chrome and doesn't work in Firefox.
– Navroop
Nov 23 '18 at 17:40
You triedsetTimeout(function() { history.go(0); }, 2000);
? Can you provide an MCVE to help us understand?
– chazsolo
Nov 23 '18 at 17:45
@chazsolo on the page which I want to refresh on click has fields like height width counter_number which are supposed to be zero on refresh. All these field refresh when I click the button in chrome but this onclick function doesnt work in firefox.
– Navroop
Nov 23 '18 at 17:55
3
3
While a string of code is a valid parameter to
setTimeout
, it is fraught with the same issues that eval
has. Why not pass a function that calls history.go(0)
instead?– chazsolo
Nov 23 '18 at 17:33
While a string of code is a valid parameter to
setTimeout
, it is fraught with the same issues that eval
has. Why not pass a function that calls history.go(0)
instead?– chazsolo
Nov 23 '18 at 17:33
@chazsolo I tried history.go(0) but it doesn't refresh all the fields on the page in the chrome and doesn't work in Firefox.
– Navroop
Nov 23 '18 at 17:40
@chazsolo I tried history.go(0) but it doesn't refresh all the fields on the page in the chrome and doesn't work in Firefox.
– Navroop
Nov 23 '18 at 17:40
You tried
setTimeout(function() { history.go(0); }, 2000);
? Can you provide an MCVE to help us understand?– chazsolo
Nov 23 '18 at 17:45
You tried
setTimeout(function() { history.go(0); }, 2000);
? Can you provide an MCVE to help us understand?– chazsolo
Nov 23 '18 at 17:45
@chazsolo on the page which I want to refresh on click has fields like height width counter_number which are supposed to be zero on refresh. All these field refresh when I click the button in chrome but this onclick function doesnt work in firefox.
– Navroop
Nov 23 '18 at 17:55
@chazsolo on the page which I want to refresh on click has fields like height width counter_number which are supposed to be zero on refresh. All these field refresh when I click the button in chrome but this onclick function doesnt work in firefox.
– Navroop
Nov 23 '18 at 17:55
add a comment |
1 Answer
1
active
oldest
votes
This is how I made it work.
<input type="submit" name="add" class="buy" onClick="timeDelay()"/>
<script>
function timeDelay(){
setTimeout(function(){
window.location.reload(true);
},6000);
}
</script>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450864%2fsettimeout-function-not-working-on-firefox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is how I made it work.
<input type="submit" name="add" class="buy" onClick="timeDelay()"/>
<script>
function timeDelay(){
setTimeout(function(){
window.location.reload(true);
},6000);
}
</script>
add a comment |
This is how I made it work.
<input type="submit" name="add" class="buy" onClick="timeDelay()"/>
<script>
function timeDelay(){
setTimeout(function(){
window.location.reload(true);
},6000);
}
</script>
add a comment |
This is how I made it work.
<input type="submit" name="add" class="buy" onClick="timeDelay()"/>
<script>
function timeDelay(){
setTimeout(function(){
window.location.reload(true);
},6000);
}
</script>
This is how I made it work.
<input type="submit" name="add" class="buy" onClick="timeDelay()"/>
<script>
function timeDelay(){
setTimeout(function(){
window.location.reload(true);
},6000);
}
</script>
answered Nov 23 '18 at 20:56
Navroop Navroop
468
468
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53450864%2fsettimeout-function-not-working-on-firefox%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
While a string of code is a valid parameter to
setTimeout
, it is fraught with the same issues thateval
has. Why not pass a function that callshistory.go(0)
instead?– chazsolo
Nov 23 '18 at 17:33
@chazsolo I tried history.go(0) but it doesn't refresh all the fields on the page in the chrome and doesn't work in Firefox.
– Navroop
Nov 23 '18 at 17:40
You tried
setTimeout(function() { history.go(0); }, 2000);
? Can you provide an MCVE to help us understand?– chazsolo
Nov 23 '18 at 17:45
@chazsolo on the page which I want to refresh on click has fields like height width counter_number which are supposed to be zero on refresh. All these field refresh when I click the button in chrome but this onclick function doesnt work in firefox.
– Navroop
Nov 23 '18 at 17:55