Solved

window.resize()

Posted on 2013-12-03
2
142 Views
Last Modified: 2013-12-03
Is there a way to run a script when the window width changes only and not when the window height changes?
At the moment I am using $(window).resize(functionname) but this obviously fires when the window size changes vertically or horizontally.

Thanks
0
Comment
Question by:Al4ddin2
2 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39692522
Hi,
there is no specific event for width change - you still have to use the resize event and then check the original and new width like:
var orgwidth = $(window).width();
$(window).resize(function(){
   if($(this).width() != orgwidth ){
      // Update the window check width
      orgwidth = $(this).width();
       // Anything you want to do when the width changes
   }
});

Open in new window


HTH
Rainer
0
 

Author Comment

by:Al4ddin2
ID: 39692574
perfect, thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
HTML5 frame 5 26
PHP Form Calculate Total Price 10 43
filter portfolio grid display on page load (wordpress) 7 20
key press alert 2 19
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question