문제

EDIT: Why doesn't this work?

@match http://tumblr.com/*
$(document).ready(function() {
    $(img).each(function() {
        var i = $(this).attr("src");
        var n = i.replace("http://", "https://");
        $(this).attr("src", function() {
            return n;
        });
    });
});​

EDIT: To be clear, I DO NOT OWN THE WEBSITE. I want to have images on sites like https://facebook.com/ and https://tumblr.com/ be on https.

도움이 되었습니까?

해결책 2

The OP was really close, just need to tweak the selector: $(img) to $("img")

$(document).ready(function() {
        $("img").each(function() {
          var link = $(this).attr("src");
          var newLink = link.replace("http://example.com", "//example.com");
          $(this).attr("src", function() {
            return newLink
        });
     });
  });

jQuery requires the use of quotes around DOM element selectors, the OP script would throw img not defined.

다른 팁

hey man it's so simple as far i can understand that you want! You want to change all images src?

$(document).ready( function() {
$("img").each( function() {
var i = $(this).attr("src");
var n = i.replace("http://", "https://");
$(this).attr("src", function() {
return n;
});
});
});
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top