1
안녕하세요이 스크립트를 가지고 :내 자바 스크립트에서 링크의 클래스를 감지하는 방법?
function ajax(){
if (navigator.standalone) return;
for (var i= document.links.length; i-->0;) {
document.links[i].onclick= function() {
var req= new XMLHttpRequest();
req.onreadystatechange= function() {
if (this.readyState!==4) return;
document.body.innerHTML= this.responseText;
ajax();
};
req.open('GET', this.href, true);
req.send();
return false;
};}
}
window.onload= function() {
window.scrollTo(0, 0.9);
ajax();
};
지금 난 그냥 1 작은 일을 추가 할 수 있습니다. 링크는 "noeffect"라는 클래스가있는 경우 아약스는 .I've 뭔가 시도 (annother 페이지를로드한다)을 실행하지 않아야하지만 난이 제대로 그냥 자바 스크립트로 충분하지 오전 : 내가 생각
function ajax(){
if (navigator.standalone) return;
for (var i= document.links.length; i-->0;) {
if (document.links[i].getAttribute("class") == "noeffect") return;
document.links[i].onclick= function() {
var req= new XMLHttpRequest();
req.onreadystatechange= function() {
if (this.readyState!==4) return;
document.body.innerHTML= this.responseText;
ajax();
};
req.open('GET', this.href, true);
req.send();
return false;
};}
}
window.onload= function() {
window.scrollTo(0, 0.9);
ajax();
};
을 그것은 각각의 링크 대신에 모든 링크를 검사하지만 올바른 방법으로 코드하는 법을 모르겠습니다. : s
예상되는 동작은 무엇입니까? 무슨 일 이니? – Dan
아무 일도 없었습니다. 하지만 난 이미 그것을 해결, 어쨌든 감사합니다 :) – cmplieger