How to call a function on div resize?
There is a new CSS property, called resize, so the divs are resizeable too. But how to attach an event listener? Because .onresize
works only on the window object
JSFiddle: http://jsfiddle.net/3y0gfj8j/
Edit:
I don't want to use JQuery. It's not a duplicate question.
I've found only JQuery solutions for this problem, that's why I asked this question.
javascript html css javascript-events
|
show 3 more comments
There is a new CSS property, called resize, so the divs are resizeable too. But how to attach an event listener? Because .onresize
works only on the window object
JSFiddle: http://jsfiddle.net/3y0gfj8j/
Edit:
I don't want to use JQuery. It's not a duplicate question.
I've found only JQuery solutions for this problem, that's why I asked this question.
javascript html css javascript-events
1
Duplicate: stackoverflow.com/questions/8082729/…
– Andreas Furster
Sep 30 '14 at 8:51
3
I don't want to use JQuery. It's not a duplicate
– Iter Ator
Sep 30 '14 at 8:52
1
DOMAttrModified doesn't works in chrome
– Iter Ator
Sep 30 '14 at 8:56
4
I've found only JQuery solutions for this problem, that's why I asked this question. Stop posting possible duplicates please
– Iter Ator
Sep 30 '14 at 9:02
1
@IterAtor You're right, I've retracted my close vote.
– MarioDS
Sep 30 '14 at 9:14
|
show 3 more comments
There is a new CSS property, called resize, so the divs are resizeable too. But how to attach an event listener? Because .onresize
works only on the window object
JSFiddle: http://jsfiddle.net/3y0gfj8j/
Edit:
I don't want to use JQuery. It's not a duplicate question.
I've found only JQuery solutions for this problem, that's why I asked this question.
javascript html css javascript-events
There is a new CSS property, called resize, so the divs are resizeable too. But how to attach an event listener? Because .onresize
works only on the window object
JSFiddle: http://jsfiddle.net/3y0gfj8j/
Edit:
I don't want to use JQuery. It's not a duplicate question.
I've found only JQuery solutions for this problem, that's why I asked this question.
javascript html css javascript-events
javascript html css javascript-events
edited Jun 2 '16 at 19:06
Iter Ator
asked Sep 30 '14 at 8:47
Iter AtorIter Ator
2,12473480
2,12473480
1
Duplicate: stackoverflow.com/questions/8082729/…
– Andreas Furster
Sep 30 '14 at 8:51
3
I don't want to use JQuery. It's not a duplicate
– Iter Ator
Sep 30 '14 at 8:52
1
DOMAttrModified doesn't works in chrome
– Iter Ator
Sep 30 '14 at 8:56
4
I've found only JQuery solutions for this problem, that's why I asked this question. Stop posting possible duplicates please
– Iter Ator
Sep 30 '14 at 9:02
1
@IterAtor You're right, I've retracted my close vote.
– MarioDS
Sep 30 '14 at 9:14
|
show 3 more comments
1
Duplicate: stackoverflow.com/questions/8082729/…
– Andreas Furster
Sep 30 '14 at 8:51
3
I don't want to use JQuery. It's not a duplicate
– Iter Ator
Sep 30 '14 at 8:52
1
DOMAttrModified doesn't works in chrome
– Iter Ator
Sep 30 '14 at 8:56
4
I've found only JQuery solutions for this problem, that's why I asked this question. Stop posting possible duplicates please
– Iter Ator
Sep 30 '14 at 9:02
1
@IterAtor You're right, I've retracted my close vote.
– MarioDS
Sep 30 '14 at 9:14
1
1
Duplicate: stackoverflow.com/questions/8082729/…
– Andreas Furster
Sep 30 '14 at 8:51
Duplicate: stackoverflow.com/questions/8082729/…
– Andreas Furster
Sep 30 '14 at 8:51
3
3
I don't want to use JQuery. It's not a duplicate
– Iter Ator
Sep 30 '14 at 8:52
I don't want to use JQuery. It's not a duplicate
– Iter Ator
Sep 30 '14 at 8:52
1
1
DOMAttrModified doesn't works in chrome
– Iter Ator
Sep 30 '14 at 8:56
DOMAttrModified doesn't works in chrome
– Iter Ator
Sep 30 '14 at 8:56
4
4
I've found only JQuery solutions for this problem, that's why I asked this question. Stop posting possible duplicates please
– Iter Ator
Sep 30 '14 at 9:02
I've found only JQuery solutions for this problem, that's why I asked this question. Stop posting possible duplicates please
– Iter Ator
Sep 30 '14 at 9:02
1
1
@IterAtor You're right, I've retracted my close vote.
– MarioDS
Sep 30 '14 at 9:14
@IterAtor You're right, I've retracted my close vote.
– MarioDS
Sep 30 '14 at 9:14
|
show 3 more comments
3 Answers
3
active
oldest
votes
I worked around it this way. Seems to work OK in Firefox at least.
It fires when you take your cursor off the resize 'grabber' on the bottom right of the element you're resizing.
<DOCTYPE=html>
<html>
<script>
function functionname()
//replace this line with the script you want executed
</script>
<style>
#idname resize:both;
</style>
<body>
<div id="idname" onmouseout="functionname();"></div>
</body>
</html>
add a comment |
This is a different way to approach the problem. Add your own "handle" (smaller element that you can capture the mousedown
mouseup
events. Not sure if this will help you.
building interactive elements with html and javascript resizing
Another partial option: This feature isn't common yet, but works in Chrome: resizeObserver
stackoverflow question
add a comment |
This is a real problem in todays DOM. Modern browsers support underflow/overflow events that can be used to detect resizing, and IE support the non-standard resize event. The problem is, that IE11 removed that non-standard event and didn't provide any alternative, so you need to use hacks upon hacks sadly. A working hack can be found here:
http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
1
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26116507%2fhow-to-call-a-function-on-div-resize%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I worked around it this way. Seems to work OK in Firefox at least.
It fires when you take your cursor off the resize 'grabber' on the bottom right of the element you're resizing.
<DOCTYPE=html>
<html>
<script>
function functionname()
//replace this line with the script you want executed
</script>
<style>
#idname resize:both;
</style>
<body>
<div id="idname" onmouseout="functionname();"></div>
</body>
</html>
add a comment |
I worked around it this way. Seems to work OK in Firefox at least.
It fires when you take your cursor off the resize 'grabber' on the bottom right of the element you're resizing.
<DOCTYPE=html>
<html>
<script>
function functionname()
//replace this line with the script you want executed
</script>
<style>
#idname resize:both;
</style>
<body>
<div id="idname" onmouseout="functionname();"></div>
</body>
</html>
add a comment |
I worked around it this way. Seems to work OK in Firefox at least.
It fires when you take your cursor off the resize 'grabber' on the bottom right of the element you're resizing.
<DOCTYPE=html>
<html>
<script>
function functionname()
//replace this line with the script you want executed
</script>
<style>
#idname resize:both;
</style>
<body>
<div id="idname" onmouseout="functionname();"></div>
</body>
</html>
I worked around it this way. Seems to work OK in Firefox at least.
It fires when you take your cursor off the resize 'grabber' on the bottom right of the element you're resizing.
<DOCTYPE=html>
<html>
<script>
function functionname()
//replace this line with the script you want executed
</script>
<style>
#idname resize:both;
</style>
<body>
<div id="idname" onmouseout="functionname();"></div>
</body>
</html>
answered Nov 14 '18 at 23:54
Ed WouldEd Would
364
364
add a comment |
add a comment |
This is a different way to approach the problem. Add your own "handle" (smaller element that you can capture the mousedown
mouseup
events. Not sure if this will help you.
building interactive elements with html and javascript resizing
Another partial option: This feature isn't common yet, but works in Chrome: resizeObserver
stackoverflow question
add a comment |
This is a different way to approach the problem. Add your own "handle" (smaller element that you can capture the mousedown
mouseup
events. Not sure if this will help you.
building interactive elements with html and javascript resizing
Another partial option: This feature isn't common yet, but works in Chrome: resizeObserver
stackoverflow question
add a comment |
This is a different way to approach the problem. Add your own "handle" (smaller element that you can capture the mousedown
mouseup
events. Not sure if this will help you.
building interactive elements with html and javascript resizing
Another partial option: This feature isn't common yet, but works in Chrome: resizeObserver
stackoverflow question
This is a different way to approach the problem. Add your own "handle" (smaller element that you can capture the mousedown
mouseup
events. Not sure if this will help you.
building interactive elements with html and javascript resizing
Another partial option: This feature isn't common yet, but works in Chrome: resizeObserver
stackoverflow question
edited Nov 15 '18 at 0:58
answered Nov 15 '18 at 0:47
hjelmeirhjelmeir
4118
4118
add a comment |
add a comment |
This is a real problem in todays DOM. Modern browsers support underflow/overflow events that can be used to detect resizing, and IE support the non-standard resize event. The problem is, that IE11 removed that non-standard event and didn't provide any alternative, so you need to use hacks upon hacks sadly. A working hack can be found here:
http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
1
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
add a comment |
This is a real problem in todays DOM. Modern browsers support underflow/overflow events that can be used to detect resizing, and IE support the non-standard resize event. The problem is, that IE11 removed that non-standard event and didn't provide any alternative, so you need to use hacks upon hacks sadly. A working hack can be found here:
http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
1
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
add a comment |
This is a real problem in todays DOM. Modern browsers support underflow/overflow events that can be used to detect resizing, and IE support the non-standard resize event. The problem is, that IE11 removed that non-standard event and didn't provide any alternative, so you need to use hacks upon hacks sadly. A working hack can be found here:
http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/
This is a real problem in todays DOM. Modern browsers support underflow/overflow events that can be used to detect resizing, and IE support the non-standard resize event. The problem is, that IE11 removed that non-standard event and didn't provide any alternative, so you need to use hacks upon hacks sadly. A working hack can be found here:
http://www.backalleycoder.com/2013/03/18/cross-browser-event-based-element-resize-detection/
answered Sep 30 '14 at 9:05
ZenorbiZenorbi
1,331916
1,331916
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
1
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
add a comment |
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
1
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
It doesn't work for the resizeable div
– Iter Ator
Sep 30 '14 at 9:20
1
1
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
I've modified the code, so it now works: fiddle.jshell.net/tfrp22hb/3
– Zenorbi
Sep 30 '14 at 10:46
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26116507%2fhow-to-call-a-function-on-div-resize%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Duplicate: stackoverflow.com/questions/8082729/…
– Andreas Furster
Sep 30 '14 at 8:51
3
I don't want to use JQuery. It's not a duplicate
– Iter Ator
Sep 30 '14 at 8:52
1
DOMAttrModified doesn't works in chrome
– Iter Ator
Sep 30 '14 at 8:56
4
I've found only JQuery solutions for this problem, that's why I asked this question. Stop posting possible duplicates please
– Iter Ator
Sep 30 '14 at 9:02
1
@IterAtor You're right, I've retracted my close vote.
– MarioDS
Sep 30 '14 at 9:14