당신은 자바 스크립트 (jQuery를 필요)를 사용할 수 있습니다 아래의 코드 : 자바 스크립트를 사용하여 다음
mysite.com/donate.html?www.yoursite.com.otherpage.html
과 donate
클래스입니다. page1.html 및 page2.html에
JS
$(document).ready(function() {
$('a.donate').click(function() {
// Retrieve the href value and store it in a variable.
var href = $(this).attr('href');
// Redirect a user to the desired page and passes the href value in query string.
window.location.href = 'http://example.com/donate.html?href=' + href;
// Ensure the original click event handler is not triggered.
return false;
})
});
쿼리 문자열을 구문 분석합니다 (href
의 값을 얻을 수 있습니다 사용자가 기부 페이지로 리디렉션됩니다 링크를 클릭 한 후 이전 페이지의 <a href="...">
에있는 내용입니다).
쿼리 문자열을 구문 분석하는 데는 여러 가지 방법이 있지만 다음 빠른 & 더티 코드를 사용해야합니다. donate.html에
JS 여기
var location = document.location.href;
var queryString = location.split('?')[1];
// In the href variable is now what you are looking for.
var href = queryString.substr(5);
고마워요. @Anton, 제게이 작은 튜토리얼을 주시겠습니까? 아직 초보자입니다. 나는이 라인들을 어디에서 더할 것인지를 의미한다. –
@ aton에게 고마워하지만 그것은 나를 위해 작동하지 않았다. –