Bonjour,
J'ai un sousis que je ne parvient pas a résoudre.
en faite quand je place un événement en Jquery pour recuperer le scroll de la molette de la souris, ca marche que dans la page sans Iframe et dans l'Iframe ce meme code ne fonctionne pas.
Je vous montre l'exemple de code
La page ou j'ai mon Iframe
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> <head> <script src="Data/Noyau/Js/jquery.min.js" type="text/javascript"></script> </head> <body> <iframe src="teste_frame.php" align="center" width="100%" frameborder="0" scrolling="no" id="iframe0"></iframe> </body> </html>
et la page de l'Iframe (ou l'appel $(this).wheel() ne fonctionne pas)
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> <head> <script src="Data/Noyau/Js/jquery.min.js" type="text/javascript"></script> </head> <body> <script> $.fn.wheel = function (callback) { return this.each(function () { $(this).on('mousewheel DOMMouseScroll', function (e) { e.delta = null; if (e.originalEvent) { if (e.originalEvent.wheelDelta) e.delta = e.originalEvent.wheelDelta / -40; if (e.originalEvent.deltaY) e.delta = e.originalEvent.deltaY; if (e.originalEvent.detail) e.delta = e.originalEvent.detail; } if (typeof callback == 'function') { callback.call(this, e); } }); }); }; $(this).wheel(function(e) { e.preventDefault(); alert("scrool"); }); </script> </body> </html>
Par contre si je fait (sur la page qui appel l'iframe)
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> <head> <script src="Data/Noyau/Js/jquery.min.js" type="text/javascript"></script> </head> <body> <iframe src="teste_frame.php" align="center" width="100%" frameborder="0" scrolling="no" id="iframe0"></iframe> <script> $.fn.wheel = function (callback) { return this.each(function () { $(this).on('mousewheel DOMMouseScroll', function (e) { e.delta = null; if (e.originalEvent) { if (e.originalEvent.wheelDelta) e.delta = e.originalEvent.wheelDelta / -40; if (e.originalEvent.deltaY) e.delta = e.originalEvent.deltaY; if (e.originalEvent.detail) e.delta = e.originalEvent.detail; } if (typeof callback == 'function') { callback.call(this, e); } }); }); }; $(this).wheel(function(e) { e.preventDefault(); alert("scrool"); }); </script> </body> </html>
La sa fonctionne.
Pourquoi ça ne fonctionne pas dans l'iframe ?
Merci pour votre aide.
Partager