View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
04272Bug reportsLimeSurvey Websitepublic2010-05-05 10:28
Reporterjas Assigned Tolemeur  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.85+ 
Fixed in Version1.90b 
Summary04272: disable scrollwheel in listboxes/dropdownboxes
Description

The mousewheel is often used by users to scroll the webpages of a survey. When the focus is on a dropdown-box/listbox, not the webpage is scrolled, but the items in that control.
The user can thus change his selection without even knowing. This is a serious risk.

Steps To Reproduce

set the focus on a dropdownbox and scoll the mousewheel.

Additional Information

Solution we implemented:

  1. a javascript
  2. some minor changes to common.php

The mousewheel stays function when the focus is NOT on a dropdownbox/listbox
(questiontypes 'W' and "!")


1.javascript: scrollmouse.js
function hookEvent(element, eventName, callback)
{
if(typeof(element) == "string")
element = document.getElementById(element);
if(element == null)
return;
if(element.addEventListener)
{
if(eventName == 'mousewheel')
element.addEventListener('DOMMouseScroll', callback, false);
element.addEventListener(eventName, callback, false);
}
else if(element.attachEvent)
element.attachEvent("on" + eventName, callback);
}

function cancelEvent(e)
{
e = e ? e : window.event;
if(e.stopPropagation)
e.stopPropagation();
if(e.preventDefault)
e.preventDefault();
e.cancelBubble = true;
e.cancel = true;
e.returnValue = false;
return false;
}

function noScroll(e)
{
e = e ? e : window.event;
cancelEvent(e);
}


  1. additions to common.php
    Common.php, function getFooter()
    function getFooter()

    //added by A2hankes
    global $dbprefix, $connect,$surveyid;
    $query = "SELECT CONCAT('answer$surveyid','X',gid,'X',qid) AS select_id FROM lime_questions WHERE type='W' OR TYPE='!';";
    $result=db_execute_num($query) or safe_die ("Couldn't get select id's to prevent mousescroll<br />$query<br />".$connect->ErrorMsg()); //Checked
    $ayh_script="<!--added by a2hankes--><script type='text/javascript'>";
    while($row=$result->FetchRow())

    $ayh_script.=&quot;hookEvent('&quot;.$row[0].&quot;','mousewheel',noScroll);&quot;;

    $ayh_script.="</script>";
    global $embedded;

    if ( !$embedded )

    return &quot;\n\n$ayh_script\n\n\t&lt;/body>\n&lt;/html>\n&quot;;

    global $embedded_footerfunc;

    if ( function_exists( $embedded_footerfunc ) )

    $voet = $embedded_footerfunc();

    return "\n\n$ayh_script".$voet;


Common.php, function getheader(), the last part
if ( !$embedded )

    $header=  &quot;&lt;!DOCTYPE html PUBLIC \&quot;-//W3C//DTD XHTML 1.0 Transitional//EN\&quot; \&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\&quot;>\n&quot;
            . &quot;&lt;html xmlns=\&quot;http://www.w3.org/1999/xhtml\&quot; xml:lang=\&quot;&quot;.$surveylanguage.&quot;\&quot; lang=\&quot;&quot;.$surveylanguage.&quot;\&quot;&quot;;
    if (getLanguageRTL($surveylanguage))

        $header.=&quot; dir=\&quot;rtl\&quot; &quot;;

    $header.= &quot;>\n\t&lt;head>&lt;meta http-equiv='X-UA-Compatible' content='IE=8' />\n&quot;
            . $css_header
            . &quot;\t\t&lt;script type=\&quot;text/javascript\&quot; src=\&quot;&quot;.$rooturl.&quot;/scripts/jquery/jquery.js\&quot;>&lt;/script>\n\t\t&lt;!--added by a2hankes-->&lt;script type=\&quot;text/javascript\&quot; src=\&quot;&quot;.$rooturl.&quot;/scripts/scrollmouse.js\&quot;>&lt;/script>\n&quot;
            . $js_header;

    return $header;        
TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)7689
I will donate to the project if issue is resolved
Browserie
Database type & versionmysql 5.0.90
Server OS (if known)linux
Webserver software & version (if known)apache
PHP Version5.2.12

Users monitoring this issue

There are no users monitoring this issue.

Activities

lemeur

lemeur

2010-04-24 11:06

developer   ~11642

Carsten,

I've tested that scrolling while having the focus set ont a select box only changes the answer in the following situation:

  • using IE8 AND having the mouse over the dropdown box. If the mouse is not over the dropdown box, the mousewheel will scroll the page and not change the answer.
  • on FF 3.6.3, the mousewheel is disabled in select box, so there is no such issue

Nevertheless I've adapted the fix to fit our JS structure (survey_runtime, and using JQuery instead of Javascript in header), so I'm ready to commit if you still want this.

Thibault

c_schmitz

c_schmitz

2010-04-24 11:11

administrator   ~11643

Sounds great, please do!

lemeur

lemeur

2010-04-24 11:16

developer   ~11644

k

lemeur

lemeur

2010-04-27 23:28

developer   ~11667

I've tweaked the patch a little so that it requires only Javascript and no php at all. (Everything implemented in jQuery).

Implemented in rev 8625.

Thanks,
Thibault

Issue History

Date Modified Username Field Change
2010-04-09 09:53 jas New Issue
2010-04-11 00:31 c_schmitz Status new => assigned
2010-04-11 00:31 c_schmitz Assigned To => lemeur
2010-04-24 11:03 lemeur Assigned To lemeur => c_schmitz
2010-04-24 11:06 lemeur Note Added: 11642
2010-04-24 11:06 lemeur Status assigned => acknowledged
2010-04-24 11:11 c_schmitz Note Added: 11643
2010-04-24 11:15 lemeur Status acknowledged => assigned
2010-04-24 11:15 lemeur Assigned To c_schmitz => lemeur
2010-04-24 11:16 lemeur Note Added: 11644
2010-04-27 23:28 lemeur Note Added: 11667
2010-04-27 23:28 lemeur Status assigned => resolved
2010-04-27 23:28 lemeur Fixed in Version => 1.90b
2010-04-27 23:28 lemeur Resolution open => fixed
2010-05-05 10:28 c_schmitz Status resolved => closed