js и браузеры

Discussion in 'PHP' started by vorona, 18 Oct 2010.

  1. vorona

    vorona Member

    Joined:
    7 Sep 2009
    Messages:
    392
    Likes Received:
    7
    Reputations:
    1
    Добрый вечер. Скажите пжлст, почему написанный js выполняется только в IE?

    PHP:
    <script language="JavaScript">
    var 
    mfBanners = [
    [
    'http://site''1.jpg'], 
    [
    'http://site''2.jpg'],
    [
    'http://site''3.jpg'],
    [
    'http://site''4.jpg']
    ];
    var 
    mfIe false;
    if( 
    document.all) {
    mfIe true;}
    var 
    mfBannerIndex 0;
    function 
    mfBannerChange() {
    var 
    htmlString '<img border="0" src="'+mfBanners[mfBannerIndex][1]+'">';

    if( 
    mfIe) {
    document.all.banner.innerHTML htmlString;
    } else {
    document.layers["banner"].document.open();
    document.layers["banner"].document.writehtmlString);
    document.layers["banner"].document.close();}
    if(
    mfBannerIndex mfBanners.length 1)
    mfBannerIndex++;
    else
    mfBannerIndex 0;}
    setInterval("mfBannerChange()"2000);
    </script>

     
  2. b3

    b3 Moderator

    Joined:
    5 Dec 2004
    Messages:
    2,041
    Likes Received:
    933
    Reputations:
    199
    document.all понимает только ИЕ и Опера
     
    _________________________
  3. GRRRL Power

    GRRRL Power Elder - Старейшина

    Joined:
    13 Jul 2010
    Messages:
    823
    Likes Received:
    185
    Reputations:
    84
    getElementById спасет.
     
  4. b3

    b3 Moderator

    Joined:
    5 Dec 2004
    Messages:
    2,041
    Likes Received:
    933
    Reputations:
    199
    ага
    PHP:
    <script language="JavaScript"
    var 
    mfBanners = [ 
    [
    'http://site''1.jpg'],  
    [
    'http://site''2.jpg'], 
    [
    'http://site''3.jpg'], 
    [
    'http://site''4.jpg'
    ];
    var 
    mfIe false
    if( 
    document.all) { 
    mfIe true;

    var 
    mfBannerIndex 0;
     
    function 
    mfBannerChange() { 
    var 
    htmlString '<img border="0" src="'+mfBanners[mfBannerIndex][1]+'">'

    if( 
    mfIe) { 
    document.all.banner.innerHTML htmlString
    } else { 
    document.getElementById('banner').innerHTML htmlString

    if(
    mfBannerIndex mfBanners.length 1
    mfBannerIndex++; 
    else 
    mfBannerIndex 0;
    }
     
    setInterval("mfBannerChange()"2000); 
    </script>
    <div id="banner"></div>
     
    _________________________
    1 person likes this.
  5. vorona

    vorona Member

    Joined:
    7 Sep 2009
    Messages:
    392
    Likes Received:
    7
    Reputations:
    1
    Огромное спасибо!