JQuery :: Browser Window Size Change Event?
Jun 25, 2009Does jquery have an event defined for when the user changes the size of his browser window? I couldn't find one, but sometimes I don't see the forest for the trees.
View 2 RepliesDoes jquery have an event defined for when the user changes the size of his browser window? I couldn't find one, but sometimes I don't see the forest for the trees.
View 2 RepliesThe problem:
I have an XHTML STRICT page which has some event listeners attached for onload and resize. I'm doing a bit of Javascript DHTML on these events. When a user changes the browser font size, the javascipt function needs to run. Although the TOPMENU DIV gets resized when the font changes size, its not a page resize so the function doesn't get run. I fixed this in IE6 by using a second function which is run onload and sets an event on the div object in the page after its been defined.
Problem is this doesn't work in Firefox.
Mozilla DOM reference says there is no resize event on a DIV so is there a work around to make it work in FIREFOX? i.e. can I force a resize event to happen on a div in firefox or is there some other event I can trap when a user changes the browser font size?
here's my js code: topmenu is what I'm trying to trap the resize event from.
this code is loaded in the head of the page.
function maindiv(){
estartup=document.getElementById("startup");
econtain=document.getElementById("contain");
emain=document.getElementById("main");
etopmenu=document.getElementById("topmenu");
emaincontent=document.getElementById("maincontent");
nopx = document.childNodes ? 'px' : 0;
contw = document.body.clientWidth - 80;
conth = document.body.clientHeight - 80;
if (contw < 0) { contw = 0;}
if (conth < 0) { conth = 0;}
econtain.style.width = contw+nopx;
econtain.style.height = conth+nopx;
if (conth >= 100 + etopmenu.clientHeight) {
emain.style.height = (conth - etopmenu.clientHeight - 100 )+nopx;
}
if (contw >= 172) {
emaincontent.style.width = (contw - 172 )+nopx;
}
estartup.style.visibility = 'hidden'
}
function fsize() {
etm=document.getElementById("topmenu");
if (typeof window.addEventListener != 'undefined')
{
etm.addEventListener("resize", maindiv, false);
}
else if (typeof document.addEventListener != 'undefined')
{
etm.addEventListener("resize", maindiv, false);
}
else if (typeof window.attachEvent != 'undefined')
{
etm.attachEvent("onresize", maindiv);}
else
{
window.alert('Failed to attach an Event Listener
Please Report');
}
}
if (typeof window.addEventListener != 'undefined')
{
window.addEventListener("load", maindiv, false);
window.addEventListener("load", fsize, false);
window.addEventListener("resize", maindiv, false);
}
else if (typeof document.addEventListener != 'undefined')
{
document.addEventListener("load", maindiv, false);
document.addEventListener("load", fsize, false);
document.addEventListener("resize", maindiv, false);
}
else if (typeof window.attachEvent != 'undefined')
{
window.attachEvent("onload", maindiv);
window.attachEvent("onload", fsize);
window.attachEvent("onresize", maindiv);
}
else
{
window.alert('Failed to attach an Event Listener
Please Report');
}
Any clues?
where da boss wants our a large piece of our site to be fully dynamic and integrated on any screen size. This means changing font on size. Well I cam up with a solution, figured if no one has one better, then i'll share
[Code]..
I have been trying for ages to find a way of making a series of images within one div resize according to the size of the users window or their screen resolution.
how i can do this? i know jquery uses the .resize function and am hoping i could give the div with images inside a function to change size according to the window size.
I build a website with Typo3 and it works fine, except for the text size in Internet Explorer (and Opera). I tried anything from changing the CSS templates (excluding them) to changing px to pt to em and so. Finally, I think i need a Javascript that detects the browser and if it is Internet Explorer (or Opera) the textsize should be reduce by 1. It therfore should be the same like manually clicking in IE on View->text size -> smaller (default is medium).
My javascript (I just use Javascript for this single purpose) does not work/it does not do anything:
function resizeText(){ if (browserName=="Microsoft Internet Explorer") {document.body.style.fontSize = parseFloat (document.body.style.fontSize) -1 ;}}
The window.onresize is not called (in Mozilla) when changing the text size on the browser (crtl + or View/Text Zoom).
Is the xAddEventListener function usefull ? What does the "For some browsers the window.onscroll and window.onresize events are simulated." mean ?(found in the X Library function reference).
it's possible to bind a function to an element that is fired if that element is 'moved'/repositioned via the browser.
For a more specific example what I have is a function that calculates height and width of certain elements to allow them to all fit nicely on the page without having scroll bars, and this is bound to the window onresize event. It works nicely most of the time but occasionally something will change the height of one of the elements and this effectively bumps one element right off the page.
So I'm wondering if its possible to have an event bound to an element that is fired when an elements position is moved/recalculated by the browser? Short of polling every second or so, to see if it has moved/recalculate layout.
I have this code that displays all vertical buttons for sharing my content however I want to display horizontal buttons if the user is using a smaller window size. It will have a different div and some of the code wil be changed i.e. "data-count="horizontal".
It would be awesome to also do this via my external JS file so it is not inline.
But that is not essential.
Also using fluid width CSS is not an option due to my having a sidebar with ads that can't be changed in size.
Code:
<div id="sharepost"><div class="sharer"><a href="http://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-count="vertical" data-via="code_love" data-related="love:code">Tweet</a><script type="text/javascript"
[Code]....
i'm trying to do some event delegation, and i can't seem to get the onchange event working in IE. i've tried:
$(document).change(function () { alert('fuck. me. IE sux'); }); $(document.body).change(function () { alert('fuck. me. again'); });
and later i have:
<select id="aSelect"> <option value="0">a first option</option> <option value="1">a second option</option> <option value="2">a third option</option> <option value="3">a fourth option</option> </select>
but this doesn't work in IE. i've also tried to wire these up manually: document.body.onchange = function (e) { alert('foo); }; and document.onchange, but those don't work either. what's the story here (other than the fact that IE is sucking balls)?
All my font-sizes are set as relative sizes in CSS (large, medium, small,
x-small, etc). Let's say something is set in CSS to be xx-large, but a
visually impaired user wants it displayed even bigger. Can a script
determine an element's absolute size, *as it is being rendered by the
browser*, and then increment the element's font-size in absolute terms?
I'm attempting to make a web page that adapts to the size of your browser size when it maximized. Because I'm only 15 I'm not such a great programmer or coder. I've done my best with the resources I have though (Fluent in Lua and a natural ability to pick languages syntax up quickly)
Here is what I have so far, it doesn't work and it is starting to puzzle me. As it seems correct as I look at it. I'm sorry if this question show my ignorance. I try my best to hide it.
Some of it is Copy pasted from sources on Google. But only for educational purposes, I learn off reading, examining and testing out snippets.
I'm basically trying to get the max size of the window and resize the div accordingly.
I am new to Jquery mobile framework.I have an asp.net web application and I want to convert it into Jquery mobile framework.I have a datalist on an aspx page.The size of the datalist decreases according to the window size to certain extent after which the size of the datalist becomes constant and doesn't decrease with the window size.
View 2 Replies View RelatedHow can I change my text or font size when the user changes the browser size. Example: When the browser is maximized, the font goes to normal, when the browser window decreased, the font size is reduce.
View 3 Replies View RelatedI want to execute some java script code when I close the browser.In firefox clientX and clientY are getting as "undefined"..
View 9 Replies View RelatedHow do I on the change event of a list box open a new url in the current window in which the list box resides. I'm not using frames.
View 2 Replies View RelatedWhich javascript event should be used to call logout on window close and url change.
I want to call logout function on window close and URL change on my application.
I am calling logout functionon on <body onunload="doLogout();">, but onunload event is also called when refreshing the page. is there any specific event for Windoe close and URL change.
I want to resize the div based on browser size, I mean when first it load I want it to fit on browser window and no scrolling bars should be appear and when I resize the browser size by dragging, it should be fix on that size.for example visit this link:I WANT THE SAME BEHAVIOR (SIZE BASED ON BROWSER) BUT USING JQUERY.
View 2 Replies View RelatedI want to use jquery to detect what type of browser you are using and display a link to a .wmv file if you are on IE or display a link to a .mp4 file if you are any other type of browser.I have this script declaration in my <head> section.
<
script src="http://code.jquery.com/jquery-latest.js"></script>
In the body section I have the following
<div id="block"></div>
<
script type="text/javascript">[code]....
Nothing is being output on the page at all. I've tried to patch this together from various example on various web sites. How can I make this work?
I want to trap the window.close() event when the user clicks on the close button of the browser using javascript. Can anyone shed light on this problem ?
View 1 Replies View RelatedI started learning javascript couple of days ago, so this may be a noobie question.
I wrote a simple code that should re-size the image (there's some other code in here just in case) code...
I started learning javascript couple of days ago, so this may be a noobie question.
I wrote a simple code that should re-size the image (there's some other code in here just in case) code...
I'd have thought this would be easy but I've been looking for hours and all I can find is info on getting the viewport size, which is normally useful but not in my situation.
In this case I need the actual browser size, including the scrollbars, toolbars, status bars etc. to get an idea of browsers which aren't maximised/full screen and how big they are, and to calculate the amount of the screen taken up by toolbars etc too.
I need to know if the user close the browser or to open the window � browser without or with a disable close window button How can I???
View 6 Replies View RelatedI need a script that will open a new window (popup / new link) in a specific size, but will also close the old window (where the popup came from). I know the popup window is easy but finding a work-able close window script as the new window is opened is impossible!!
View 3 Replies View Relatedwhat is DOM maximum memory size? is Diff from browser to Browser?
View 1 Replies View Related