이 기능을 사용하는 데 어려움이 있습니다.변수를 window.location.hash에 전달하려고 시도했습니다.
JavaScript 목록을 사용하여 할당 목록을 만들면 text (제목)과 text2 (해시 앵커 링크, ex-slowshutter)의 두 요소가 있습니다. 그러나 링크가 작동하지 않는 것 같습니다.
var cell2 = row.insertCell(1);
var element2 = document.createElement("input");
element2.type = "viewButton";
element2.value = todoDictionary["text"];
var link= todoDictionary["text2"];
element2.id = rowID;
element2.setAttribute("onclick","window.location.hash = link");
element2.className = "viewButton";
cell2.appendChild(element2);
나는 내가 스택 오버 플로우에 여기에 표시된 발견 다른 다양한 방법을 시도했습니다,하지만 그들은 아무 일도 발생하지 않기 때문에 제대로 동작하지 않습니다.
예 : "window.location.hash = '링크'"nothign 발생 "window.location.hash = '+ link'"는 URL에 "+ 링크"를 사용하므로 오류가 발생합니다.
내가 직접에있는 링크를 넣어, 그것을 잘 작동하는 경우 : 예 "를하면 window.location.hash = '#의 slowshutter'를"
은 내가 그것을 테스트로 링크가 "텍스트 2"에서 제대로 저장됩니다 알고 "텍스트"대신 element2.value를 사용하고 제목 대신 "#slowshutter"를 사용했습니다 ...아이디어가 있으십니까? 당신은 속성 API를 사용하고 있기 때문에
노엘이
"하면 window.location.hash = '+ 링크 +"' " –
'element2.onclick = 함수() {하면 window.location.hash = 링크};! 여러분 모두 3 ' – adeneo