0

Good morning guys

I'm trying to use two jquery functions and nothing happens . Those functions are : moveTo and resizeTo . The objective of using this is to re-open the browser when the status of my object changes to guarantee that the user will notice that on real time . To test those functions , I tried this :

setInterval(function loadPage() {           
    window.moveTo(0, 0);
    window.resizeTo(screen.availWidth, screen.availHeight);
    window.focus();
}(), 5000);

Doing this, nothing happens . But I tried to insert an alert before using the window.moveBy and with this the function works . I really didn't understand why and I don't wanna use alert to show a message to the user . I'll use jquery ui dialog to show this message .

Is there any other way to do that ?

ruynunes
  • 77
  • 10
  • Executing a function inside setTimeout makes no sense. – epascarello Nov 19 '15 at 12:57
  • but I'm using setInterval – ruynunes Nov 19 '15 at 12:59
  • 1
    Um, the setInterval is not doing what you think it is doing. It is executing what the function returns. Add a console inside of your method and see that it will execute as soon as the code is executed, not 5 seconds later. – epascarello Nov 19 '15 at 12:59
  • The setInterval is to reload the page , in this case, in every 5 secs ... This works , but the function inside doesn't – ruynunes Nov 19 '15 at 13:00
  • Becuase the function inside runs ONCE. – epascarello Nov 19 '15 at 13:01
  • As I'm using here it reloads in every 5 secs , but forget about this ... Do you have any idea of how can I bring the window back to the user as I explained above ? – ruynunes Nov 19 '15 at 13:02
  • what epascarello means is: remove the () from your last line: }(), 5000); will become }, 5000); You are immediately executing the loadpage function. E.g. you don't need to specify any function name here as well. – gkempkens Nov 19 '15 at 13:02
  • just do this: setInterval(function() { window.moveTo(0, 0); window.resizeTo(screen.availWidth, screen.availHeight); window.focus(); }, 5000); – gkempkens Nov 19 '15 at 13:03
  • But once you get the code right, you are sort of out of luck http://stackoverflow.com/questions/3641648/the-javascript-resizeto-function-not-working-in-chrome-and-opera Why don't you just ask permission to run the browser in full screen mode. – epascarello Nov 19 '15 at 13:04
  • understood ... and about the moveTo and resizeTo functions ? I'm trying to use it at chrome , but nothing happens , only when I put an alert before those functions ... Am I doing wrong ? – ruynunes Nov 19 '15 at 13:05
  • Chrome has blocked resizeTo and moveTo for awhile. – epascarello Nov 19 '15 at 13:08
  • hahahah Then this doesn't work at chrome at all ? Really without any luck ... But the weird thing is , by add an alert before those functions it "works" ... but only using on that way ... – ruynunes Nov 19 '15 at 13:10
  • Guys , thanks for the help ! – ruynunes Nov 19 '15 at 13:30

0 Answers0