Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

window.resize()

Posted on 2013-12-03
2
143 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!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how can i get 4 nd 5 ? 3 31
html Uncheck Checkbox 2 25
jQuery - Add confirm message to button? 2 20
Possible propagation problem 1 22
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

839 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