www.webdeveloper.com
Results 1 to 3 of 3

Thread: [HELP]call php file when resize window!

  1. #1
    Join Date
    Apr 2011
    Posts
    67

    [HELP]call php file when resize window!

    Im wondering if its possible to call a file when the resize window match on the set variable,, do you think its possible in the codes below? it can call a php file but it will need to take a refresh just to call the another file..

    PHP Code:
    <!DOCTYPE html>
    <
    html>

    <
    head>
    <
    script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>


    <script>

    var a = $(window).width();

    if(a>=970){

        $.get("970x250.php",
        {
        //ads: "getrssfeeds",//source: 8,//site: 2584,//limit: 5,
        },

        function(data){
        $("body").append(data);
            }
        );
    }    
    else if(a>=320){
        $.get("970x90.php",
        {
        //ads: "getrssfeeds",//source: 8,//site: 2584,//limit: 5,
        },

        function(data){
        $("body").append(data);
            }
        );
    }


    </script>
    </head>

    <body>




    </body>
    </html> 

  2. #2
    Join Date
    Aug 2008
    Location
    Sweden
    Posts
    227
    Just listen for the "resize" event on the window object.

    Code:
    $(window).resize(function() {
      $('body').prepend('<div>New width: ' + $(window).width() + '</div>');
    });
    Note however that the resize event is also fired while the user is resizing the window, i.e. multiple times before the resize is complete, so you should add a delay before making the Ajax call (or else you could be making tens or possibly hundreds of requests to the server in just a few seconds)!
    New to web development or in need of a good reference? Check out the Mozilla Developer Network or W3Schools.

  3. #3
    Join Date
    Apr 2011
    Posts
    67
    its still the same. i still need to refresh just to call different file when it change to different witdh

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles