简体   繁体   English

Javascript / jquery在IE8中不起作用

[英]Javascript/jquery not working in IE8

I'm currently working on a website and it runs correctly in chrome but for some reason IE8 does not want to run any of the javascript/jquery scripts. 我目前正在网站上,它可以在chrome中正常运行,但是由于某些原因IE8不想运行任何javascript / jquery脚本。 Even when I call for an alert on page ready, it does not pop up. 即使我在页面准备就绪时发出警报,它也不会弹出。 It is a little sloppy; 这有点草率; I've included all of the css and jquery in the actual index.php file and was planning on cleaning it up eventually after I was a little farther along, but enough of my terrible excuses. 我已经将所有的css和jquery包含在实际的index.php文件中,并计划在我走得更远之后最终清理它,但我有足够的借口。 I've read that a trailing comma after an item can make a website not function correctly in IE, but I cannot find one in my code. 我读过一个项目后面的逗号可以使网站无法在IE中正常运行,但是我在代码中找不到一个。 I am still learning so I am sure there are many things that could be corrected in my code as well. 我仍在学习,因此我确定代码中还有很多可以纠正的地方。 Sorry for how long it is. 对不起多久了。 Essentially what happens is that all of the hidden divs just hang out and lay overtop one another, and none of the code executes. 本质上发生的是,所有隐藏的div都只是闲逛并彼此重叠,而没有代码执行。

<script type="text/javascript">
function video_pop(vimeo_link) {
    var vimeo_applet = "";
    $('.prompt_inner').text(vimeo_applet);
    vimeo_applet = "<div>";
    vimeo_applet += "<iframe src=\""+vimeo_link+"\" id=\"vimeo_link\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>";
    vimeo_applet += "</div>";
    $('.prompt_inner').append(vimeo_applet);
    $('.prompt_box').css("margin-left", (-(($('.prompt_inner').width())/2)));
    $('.prompt_box').css("visibility", "visible");
    $('.prompt_background').css("visibility", "visible");
    $('.prompt_box').animate({
            opacity: '1'
    }, 500);
    $('.prompt_background').animate({
            opacity: '.95'
    }, 500);
}

//MAIN MENU FUNCTIONS
function directors() {
    $('.menu').stop().fadeOut(1000).hide();
    $('#directors').stop().fadeIn(1000);
    $('#col_work').stop().fadeOut(1000).hide();
    $('#slideshow_container').stop().fadeIn(1000);
}

function contact() {
    $('.menu').stop().fadeOut(1000).hide();
    $('#main_contact').stop().fadeIn(1000);
    $('#col_work').stop().fadeOut(1000).hide();
    $('#slideshow_container').stop().fadeIn(1000);
}

function login() {
    $('.menu').stop().fadeOut(1000).hide();
    $('#login').stop().fadeIn(1000);
    $('#col_work').stop().fadeOut(1000).hide();
    $('#slideshow_container').stop().fadeIn(1000);
}

function work() {
    $('.menu').stop().fadeOut(1000).hide();
    clearInterval(slideshow_int);
    $('#slideshow_container').stop().fadeOut(1000).hide();
    $('#col_work').stop().fadeIn(1000);
}

function showmenu() {
    $('#back_button').stop().fadeOut(1000).hide();
    $('#director_set').stop().fadeOut(1000).hide();
    $('#holness').stop().hide();
    $('#pryce').stop().hide();
    $('#ntiri').stop().hide();
    $('#quiroz').stop().hide();
    $('#col_work').stop().hide();
    $('#main_menu').stop().fadeIn(1000);
    start_slideshow();
    $('#slideshow_container').stop().fadeIn(1000);
}

//DIRECTOR FILES
function director(x) {
    $('.menu').stop().fadeOut(1000);
    $('#main_menu').stop().fadeOut(1000);
    $('#col_work').stop().fadeOut(1000).hide();
    clearInterval(slideshow_int);
    $('#slideshow_container').stop().fadeOut(1000);
    $('#back_button').stop().fadeIn(1000);
    $('#director_set').stop().fadeIn(1000);

    if (x==="1") {
        $('#holness').stop().fadeIn(1000);
    }
    else if (x==="2") {
        $('#pryce').stop().fadeIn(1000);
    }
    else if (x==="3") {
        $('#ntiri').stop().fadeIn(1000);
    }
    else if (x==="4") {
        $('#quiroz').stop().fadeIn(1000);
    }
}

function start_slideshow() {
    slideshow_int = setInterval(function() { 
      $('#slides > div:first')
        .fadeOut(1000)
        .next()
        .fadeIn(1000)
        .end()
        .appendTo('#slides');
    },  5000);
}

$(document).ready(function() {
    //HIDE MENUS
    $('.menu').hide();
    $('#director_set').hide();
    $('#back_button').hide();
    $('#holness').stop().hide();
    $('#pryce').stop().hide();
    $('#ntiri').stop().hide();
    $('#quiroz').stop().hide();
    $('#col_work').stop().hide();

    video_pop("<?php 
        $query = "SELECT * FROM global WHERE id=1";
        $queryobj = mysql_query($query);
        $result = mysql_fetch_array($queryobj);
        echo $result['ovideo'] ?>");
        $('.prompt_background').click(function() {
        $('.prompt_box').animate({
            opacity: '0'
        }, 500, function() {
            $('.prompt_box').css("visibility", "hidden");
        });
        $(this).animate({
            opacity: '0'
        }, 500, function() {
            $(this).css("visibility", "hidden");
            var vimeo_applet = "";
            $('.prompt_inner').text(vimeo_applet);
        });
    });     


    //SLIDESHOW CONTROL
    $('#slides > div:gt(0)').hide();
    start_slideshow();

    //WORK MOUSEOVER
    <?php
    $queryobj = mysql_query("SELECT * FROM global_thumbnails");
    $total_global_thumbs = mysql_num_rows($queryobj);

    for ($i=1; $i<=$total_global_thumbs; $i++) {
        $queryobj = mysql_query("SELECT * FROM global_thumbnails WHERE position = {$i}"); 
        $result = mysql_fetch_array($queryobj);
        $global_still_title = strtoupper($result['title']); 
        echo "$('#global_stills img:eq(".($i-1).")').mouseover(function() {   
            $('#global_titles').text(\"{$global_still_title}\");
            });
        ";
    }
    ?>
    $('#global_stills img').mouseout(function() {
        $('#global_titles').text("");
    });
});
        </script>

i think instead of this 我想代替这个

for ($i=1; $i<=$total_global_thumbs; $i++)

try this 尝试这个

for (var i=1; i<=$total_global_thumbs; i++)

Because Without "var" declarations it won't work in IE8 . 因为如果没有“ var”声明,它将无法在IE8中使用。
once i also faced the same problem. 有一次我也面临同样的问题。 so after i did this it works for me :) 所以在我做完之后对我有用:)

尝试将所有jQuery放在$(document).ready(function(){...})之间;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM