jQuery execution bug

Posted on

Question :

I have a very strange problem, I had never encountered it.

function resizeResponsivo() {
    width = window.innerWidth,
    height = window.innerHeight;

    if ( width < 651 && keys[0]) {
        keys[0] = false;
        keys[2] = true;
    } else if (width < 493 && keys[1]) {
        keys[1] = false;
        keys[3] = true;
        $(forumBoxLast).hide(function() {

When the user enters the site, I run the function to fit the template on the page, it performs the first condition, the second it stops, but if I put an alert (); in both functions it performs normally. Example:

if ( width < 651 && keys[0]) {
else if ( width < 493 && keys[1] ) {

How can I fix this error?

Resolved content, I put the function inside a setTimeout () and it worked:)


Answer :

I believe a problem that must be solved first are the global variables
as menuBlockB .
You have to check how your jQuery onload tests.
It also checks the order that your files are running.

But I believe it can be a problem with onload .


Playing your function to run after document.ready(function(){}) would solve the problem since the .window functions of the DOM have already been loaded with the screen parameters.


Leave a Reply

Your email address will not be published. Required fields are marked *