2013-02-10 10 views
51

Sto usando la casella combinata di immagine msdropdown per creare le opzioni di selezione a discesa. quando eseguo questo codice localmente sul mio PC, tutto funziona alla grande. Ma quando lo eseguo su go daddy servers, msdropdown diventa disabilitato.

Non funziona su tutti i browser. Firebug visualizza l'errore come:

TypeError: $.browser is undefined 

Please help me con questo.

echo <<<_START 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html> 
<head> 
<title>profile</title> 
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1"> 
<meta name="generator" content="HAPedit 3.1"> 
<link rel="stylesheet" href="profile.css" type="text/css"> 
<link rel="stylesheet" type="text/css" href="dd.css" /> 
<link rel="stylesheet" href="javascript/jquery-ui.css" /> 
<script src="http://code.jquery.com/jquery-1.9.0.js"></script> 
<script src="http://code.jquery.com/jquery-migrate-1.1.0.js"></script> 
<script type="text/javascript" src="jQuery.js"></script> 
<script src="javascript/jquery-ui.js"></script> 
<script type="text/javascript" src="javascript/drop.js"></script> 
<script src="jquery.dd.min.js"></script> 
<script type="text/javascript" src="jquery.blockUI3.js"></script> 
<script type="text/javascript" src="javascript/req.js"></script> 
<link rel="stylesheet" href="css/body.css" /> 
<script> 
$(function() { 
$("#datepicker").datepicker({dateFormat: 'dd-mm-yy', minDate: 0, maxDate: "+0M +5D"  
}); 
}); 
</script> 
<script type="text/javascript"> 
    <!-- 
     function otherSelect() { 
      var other = document.getElementById("otherBox"); 
      if (document.getElementById("form3").place.options[document.getElementById("form3").place.selectedIndex].value == "other") { 
       other.style.visibility = "visible"; 
      } 
      else { 
       other.style.visibility = "hidden"; 
      } 
     } 
    //--> 
</script> 
</head> 

<body id="body"> 

<div id="container"> 
<div class="header"> 
<a href="profile.php" class="logo"> 
    <img title="Title" alt="Alter" src="images/logo.png" border="0" height="60px" width="200px"> 
</a> 
<a style="text-decoration:none; margin-top:15px; font-family:Bookman Old Style; font-size:12px; color:#FFFFFF; font-weight:bold;" href="logout.php?id='$session_id'" class="req"> 
Logout 
</a> 
<a href="notification.php?email='$encrypted_string'" class="req1"> 
<img border="0" title="Notifications" alt="Notifications" src="images/notification.png" height="60px" width="60px"><div class="text1">$numbr</div> 
</a> 
<a href="request.php?email='$encrypted_string'" class="req2"> 
<img border="0" title="requests" alt="Requests" src="images/request.png" height="60px" width="60px"><div class="text">$req</div> 
</a> 
</div> 

<div id="navigation"> 
<div id="picture"><img src="$img"> 
<h1 id="display" style="margin-left:30px;">$name</h1><hr> 
<table style="background-color:#81F781;font-family:Chaparral Pro,corbel; font- size:17px; color:#1C1C1C; width:100%;" border="1" cellpadding="25"> 
<tr><th>Requests($n)</th></tr></table> 
</div> 
</div></div> 
<div style="margin-top: 90px;" id="conte"> 

_START; 


echo <<<_START 
</div> 
<div id="accept" style="display:none"> 
<form method="post" id="form3" action="cnfrm.php"> 
<br><table border="0" style="width:100%;" cellspacing="4" cellpadding="4"><tr> <td style="font-family:Chaparral Pro,corbel; font-size:17px; color:#1C1C1C;">Meeting Date: <input type="text" id="datepicker" name="date"/></td> 
<td style="font-family:Chaparral Pro,corbel; font-size:17px; color:#1C1C1C;">@ about<input type="text" id="time" size="3">AM<input type="radio" name="time2" id="time2" value="am"> | PM<input type="radio" name="time2" id="time2" value="pm"></td></tr> 
_START; 

echo <<<H 
<tr><td valign="top" rowspan="2"> 
<select id="place" name="place" style="width:300px;" onchange="otherSelect()"> 
    <option value="" data-description="Choose your meeting place" selected="selected">Meet me @</option> 
    <option value="LC" data-image="image/msdropdown/icons/meet.png" data-description="Limbdi Corner">L.C</option> 
    <option value="VT" data-image="image/msdropdown/icons/meet.png" data-description="Vishwanath temple">V.T</option> 
    <option value="H.G" data-image="image/msdropdown/icons/meet.png" data-description="Hyderabaad Gate">H.G</option> 
    <option value="D.G Corner" data-image="image/msdropdown/icons/meet.png" data-description="Dhanrajgiri Corner">D.G corner</option> 
    <option value="Library" data-image="image/msdropdown/icons/meet.png" data-description="IIT Library">Library</option> 
    <option value="other" data-image="image/msdropdown/icons/meet.png" data-description="Add your own...">Other place</option> 
</select> </td></tr> 
H; 

Questo problema è stato risolto: msdropdown update e scaricare i file più recenti.

Grazie a tutti

+0

quale versione di jQuery stai usando –

+0

OP il codice non sembra avere '$ .browser' in esso, quindi immagino che la sua in uno dei tuoi plugin. –

+0

jquery 1.9.0 ... tuttavia ho spostato su JQuery 1.8.3 solo per scopi di test. Ora l'errore non è mostrato. Ma ancora il menu a tendina è disabilitato – user1972934

risposta

37

$.browser è stato rimosso dal JQuery 1.9. È possibile utilizzare Modernizr progetto anziché

http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed

aggiornamento per il supporto IE 10 e IE 11 (versione TRIDENT)

Per completare la risposta @ daniel.moura, ecco una versione che il supporto IE 11 e +

var matched, browser; 

jQuery.uaMatch = function(ua) { 
    ua = ua.toLowerCase(); 

    var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 
     /(webkit)[ \/]([\w.]+)/.exec(ua) || 
     /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 
     /(msie)[\s?]([\w.]+)/.exec(ua) ||  
     /(trident)(?:.*? rv:([\w.]+)|)/.exec(ua) || 
     ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 
     []; 

    return { 
     browser: match[ 1 ] || "", 
     version: match[ 2 ] || "0" 
    }; 
}; 

matched = jQuery.uaMatch(navigator.userAgent); 
//IE 11+ fix (Trident) 
matched.browser = matched.browser == 'trident' ? 'msie' : matched.browser; 
browser = {}; 

if (matched.browser) { 
    browser[ matched.browser ] = true; 
    browser.version = matched.version; 
} 

// Chrome is Webkit, but Webkit is also Safari. 
if (browser.chrome) { 
    browser.webkit = true; 
} else if (browser.webkit) { 
    browser.safari = true; 
} 

jQuery.browser = browser; 
// log removed - adds an extra dependency 
//log(jQuery.browser) 
+3

Al posto di modernizr, è possibile che si chieda perché è necessario sniffare il browser in primo luogo. –

+2

Ho aggiunto il plug-in di migrazione. Ma il problema persiste – user1972934

+0

Il plug-in di migrazione è utile solo per rilevare le funzioni rimosse o deprecate, non risolverà il problema. Qual è la tua versione di JQuery? – sdespont

7

$().live(function(){}); and jQuery.browser is undefined in jquery 1.9.0 - $ .Browser è stata sconsigliata a jQuery aggiornamento

suona come si utilizza una versione diversa di jQuery 1.9 a GoDaddy quindi o cambiare il codice o includere la migrazione plug http://code.jquery.com/jquery-migrate-1.0.0.js

+2

Ho aggiunto il plugin di migrazione. Ma il problema esiste ancora – user1972934

+0

qual è l'URL del sito /? –

+0

non è nella home page ... e per il login, è necessario un ID di dominio specifico. Quindi non sarai in grado di vedere il problema – user1972934

1

qualche parte del codice - sia il vostro codice o un plugin jQuery - sta chiamando a $.browser ottieni il tipo di browser corrente.

Tuttavia, ha all'inizio dell'anno the $.browser function was deprecated. Da allora alcuni bug sono stati archiviati contro di esso, ma poiché è deprecato, il team di jQuery ha deciso di non risolverli. Ho deciso di non fare affidamento sulla funzione.

Non vedo alcun riferimento a $.browser nel codice, quindi il problema probabilmente si trova in uno dei plugin. Per trovarlo, guarda il codice sorgente di ciascun plugin a cui hai fatto riferimento con un tag <script>.

Quanto a come risolvere il problema: Beh, dipende dal contesto. Ad esempio, forse c'è una versione aggiornata del plugin problematico. O forse puoi usare un altro plugin che fa qualcosa di simile ma non dipende da $.browser.

116

appena messo il codice .Browser $ nei tuoi js

var matched, browser; 

jQuery.uaMatch = function(ua) { 
    ua = ua.toLowerCase(); 

    var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || 
     /(webkit)[ \/]([\w.]+)/.exec(ua) || 
     /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || 
     /(msie) ([\w.]+)/.exec(ua) || 
     ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || 
     []; 

    return { 
     browser: match[ 1 ] || "", 
     version: match[ 2 ] || "0" 
    }; 
}; 

matched = jQuery.uaMatch(navigator.userAgent); 
browser = {}; 

if (matched.browser) { 
    browser[ matched.browser ] = true; 
    browser.version = matched.version; 
} 

// Chrome is Webkit, but Webkit is also Safari. 
if (browser.chrome) { 
    browser.webkit = true; 
} else if (browser.webkit) { 
    browser.safari = true; 
} 

jQuery.browser = browser; 
+3

Grazie a daniel. Hai salvato il mio problema. – fuat

+8

jQuery.browser (o $ .browser) è stato deprecato dalla versione 1.3 ed è stato rimosso dalla versione 1.9. Questa correzione però funziona per me! –

+1

Grazie, il suo lavoro per me. –

18

ho messo il seguente codice HTML nel mio codice e questo chiarito il $.del browser errore

<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script> 

Spero che questo aiuti u

+0

Ha funzionato come un fascino! – NDFA

2

ho fatto risolto utilizzando jQuery migrare collegamento specificato di seguito:

<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script> 
0

ho risolto utilizzando questo jQuery per Github

<script src="http://code.jquery.com/jquery-migrate-1.0.0.js"></script>

Si prega di fare riferimento a questo link per maggiori informazioni. https://github.com/Studio-42/elFinder/issues/469

+0

È lavoro per me. –

6

Sostituire i file jQuery con seguenti:

<script src="//code.jquery.com/jquery-1.11.3.min.js"></script> <script src="//code.jquery.com/jquery-migrate-1.2.1.min.js"></script>

+0

Grazie mille. Dopo quasi 5-6 ore di tentativi, ho risolto il problema con questo. – Shwet

Problemi correlati