어제 나는 비슷한 질문을했기 때문에 모든 외부 링크를 내 홈페이지로 리디렉션하는 방법을 알게되었습니다.리디렉션을 원하지 않는 경우를 제외하고 모든 외부 링크 리디렉션
// when the document is ready
$(document).ready(function() {
// iterate over all the anchor tags
$("a").each(function() {
// if the current link's href doesn't already contain 'www.kownleg.com'
if (this.href.indexOf('www.kownleg.com') === -1) {
// change current link to home page
this.href = 'http://www.kownleg.com';
}
});
});
하지만 지금 내가 facebook.com & twitter.com처럼, 내 홈 페이지로 리디렉션하지 않으려는 모든 링크를 제외 할, 내가 링크의 또 다른 조건을 만들려고하는 I 돈 리디렉션하고 싶지 않지만 작동하지 않습니다. 그런 다음 indexOf()
을 text()
으로 변경하려고했으나 여전히 작동하지 않습니다.
는 여기에 내가 노력이 코딩,하지만 난
// when the document is ready
$(document).ready(function() {
// iterate over all the anchor tags
$("a").each(function() {
// if the current link's href doesn't already contain 'www.kownleg.com'
if (this.href.indexOf('www.kownleg.com') === -1) {
// change current link to home page
this.href = 'http://www.kownleg.com';
}
if (this.href.indexOf('www.facebook.com') === -1) {
// change current link to home page
this.href = 'http://www.facebook.com';
}
if (this.href.indexOf('www.twitter.com') === -1) {
// change current link to home page
this.href = 'http://www.twitter.com';
}
});
});
또 다른 하나는 실패
// when the document is ready
$(document).ready(function() {
// iterate over all the anchor tags
$("a").each(function() {
// if the current link's href doesn't already contain 'www.kownleg.com'
if (this.href.indexOf('www.kownleg.com') === -1) {
// change current link to home page
this.href = 'http://www.kownleg.com';
}
if (this.href.text('www.facebook.com') === -1) {
// change current link to home page
this.href = 'http://www.facebook.com';
}
if (this.href.text('www.twitter.com') === -1) {
// change current link to home page
this.href = 'http://www.twitter.com';
}
});
});
그리고 모든 유사한 가능성 ...하지만 여전히 나를 위해 작동하지합니다.
작동하지 않습니다. : ( –