블로거 블로그로 멋진 것을하려고하고 있는데, 특정 블로그를보고있을 때 어떤 블로그인지 알고 싶습니다. . 제목 []하는 제목의 배열 인문자열 비교 (아마도 숨겨진 문자 문제 일까?)
//Get title of current blog
currentTitle = document.getElementById("post-title").innerText;
currentTitle = currentTitle.replace(/<\/?[^>]+(>|$)/g, "");
currentTitle = currentTitle.replace("/n","");
currentTitle = currentTitle.replace("/r","");
//Run through titles until you find a match
for (count = 0; count <= titles.length; count++)
{
//alert(currentTitle);
//alert(titles[count]);
if (titles[count] != null)
{
checkTitle = titles[count];
checkTitle = checkTitle.replace(/<\/?[^>]+(>|$)/g, "");
checkTitle = checkTitle.replace("/n","");
checkTitle = checkTitle.replace("/r","");
alert(checkTitle.toString()+" + "+currentTitle.toString());
if (checkTitle.toString() == currentTitle.toString())
{
alert(count);
}
}
}
는 RSS 피드에서 읽기 : 그 일을 더 나은 방법이있을 수도 있지만
그래서, 나는 코드의이 비트가 설정있어 (아이디어는, 내가 제목에 대한 색인을 얻으면, 나는 그 피드에서 읽은 또 다른 배열에 적용 할 수있다).
첫 번째 경고는 동일한 것으로 보이는 두 개의 문자열을 생성하지만, if ... 문은 해당 문자열을 선택하지 않습니다. 두 변수를 같은 문자열로 설정하는 줄을 추가했습니다. 내가 생각할 수있는 유일한 해결책은 문자열 중 하나에 숨겨진 캐릭터 나 무언가가 빠져 있다는 것입니다. 그러나 나는 그것들 모두를 다 커버했다고 생각합니다! 누구든지 아이디어가있어?
공백 또는 공백을 확인 했습니까? – Samuel