1

Good day,

I am very new to the world of coding, and need some help from experts. Below is the javascript error I have noticed in the jQuery(document) file:

Uncaught TypeError: Cannot read property 'indexOf' of undefined

The error is being pointed to this: if (url.indexOf("?") != -1) {

Your assistance will be much appreciated.

jQuery(document).ready(

    //tabs

    function($) {
         "use strict";
        $('.tabber-container').each(function() {
            $(this).find(".tabber-content").hide();
            $(this).find("ul.tabs li:first").addClass("active").show();
            $(this).find(".tabber-content:first").show();
        });
        $("ul.tabs li").click(
                function(e) {
                    $(this).parents('.tabber-container').find("ul.tabs li")
                            .removeClass("active");
                    $(this).addClass("active");
                    $(this).parents('.tabber-container').find(
                            ".tabber-content").hide();
                    var activeTab = $(this).find("a").attr("href");
                    $(this).parents('.tabber-container').find(activeTab)
                            .fadeIn();
                    e.preventDefault();
                });
        $("ul.tabs li a").click(function(e) {
            e.preventDefault();
        });

        //ticker

    function tick(){
    $("ul.ticker-list li:first").animate({marginLeft : '-200px'},400,function() {$(this).detach().appendTo("ul.ticker-list").removeAttr("style");
        });
    }

    var interval = setInterval(tick, 5000);

        $('ul.ticker-list li').hover(function() {
            clearInterval(interval);
        }, function() {
            interval = setInterval(tick, 5000);
        });

  //Gallery slider
          $('.post-page-gallery-thumbnails').flexslider({
            animation: 'slide',
            controlNav: false,
            animationLoop: false,
            slideshow: false,
            itemWidth: 121,
            itemMargin: 1,
            directionNav: true,
            asNavFor: '.post-page-gallery-slider'
          });

          $('.post-page-gallery-slider').flexslider({
            animation: 'fade',
            controlNav: false,
            animationLoop: false,
            slideshow: false,
            sync: '.post-page-gallery-thumbnails'
          });

        //carousel

        $('.carousel').flexslider({
            animation : 'slide',
            itemWidth : 161,
            itemMargin : 16,
            move : 2,
            slideshow : false,
            start : function() {
                $('.carousel li').css('visibility', 'visible');
            },
        });

        //video type page carousel

        $('.tv-carousel').flexslider({
            animation : 'slide',
            itemWidth : 161,
            itemMargin : 16,
            move : 2,
            slideshow : false,
            controlNav : false
        });

        //video type page ajax

        $('.ajax').click(
                function(event) {
                    event.preventDefault();
                    var post_id = $(this).attr("href");

                    jQuery.ajax({
                        post : post_id,
                        type : "POST",
                        data : {id : post_id},
                        success : function(output) {
                            $(".tv-video-wrapper").replaceWith(
                                    $('.tv-video-wrapper', output));
                        }
                    });
                });

        //keyboard navigation next prev         
           $(document).keydown(function(e) {
                var url = false;
            if (e.which == 37) {  // Left arrow key code
                    url = $('.previous-title a').attr('href');
                }
            else if (e.which == 39) {  // Right arrow key code
                    url = $('.next-title a').attr('href');
            }
            if (url) {
                    window.location = url;
            }
        });

        //menu button for responsive mobile


        $("#mob-menu").click(function() {
            $("#main-nav ul").toggleClass("active");
            $(this).toggleClass("active");

        });

        //back to top button

        $('.back-2-top').click(function() {
            $('html, body').animate({
                scrollTop : 0
            }, 'fast');
            return false;
        });

        //hover for Three-posts

        $(".three-posts li").hover(
              function () {
                $(".three-posts li").removeClass('three-hover');
                $(this).addClass('three-hover');
              });

        //simple IE fix for iframe embeds z-index

        $('iframe').each(function() {
            var url = $(this).attr("src");
            var char = "?";
            if (url.indexOf("?") != -1) {
                var char = "&";
            }
            $(this).attr("src", url + char + "wmode=transparent");
        });
    });
maxhb
  • 7,819
  • 9
  • 25
  • 50
S.Mic
  • 11
  • 3

1 Answers1

0

Use:

var url = this.contentWindow.location.href;

to get the URL instead of:

var url =$(this).attr("src");

NiallMitch14
  • 1,045
  • 1
  • 11
  • 22
  • I found this answer. Apparently you can only access the url of an iframe if the protocol, hostname and port of the iframe is the same as your domain. There is a workaround in that answer you can try: http://stackoverflow.com/a/25098153/4611941 – NiallMitch14 Feb 18 '16 at 12:44