美好的一天,
我对编码世界很陌生,需要专家的帮助。下面是我在jQuery(文档)文件中注意到的javascript错误:
未捕获的TypeError:无法读取未定义的属性“indexOf”
指出错误:if (url.indexOf("?") != -1) {
非常感谢您的协助。
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");
});
});
答案 0 :(得分:0)
使用:
var url = this.contentWindow.location.href;
获取网址而不是:
var url =$(this).attr("src");