2012-04-22 4 views
0

에서 링크를 실행 3d, 코드 및 비디오. 또한 내가 선택한 카테고리의 작업 만 보여주는 필터 스크립트가 포함되어 있습니다.내가 2 개 HTML 파일을 외부 html 파일

index.html에서 내 포트폴리오의 각 카테고리로 연결되는 링크가 필요하지만이 작업을 수행하는 방법을 모르겠습니다.

에 Index.html :

... 
<a href="portfolio.html#web"><img src="img/web.png"></a> 
<a href="portfolio.html#triD"><img src="img/triD.png"></a> 
<a href="portfolio.html#codes"><img src="img/codes.png"></a> 
<a href="portfolio.html#video"><img src="img/video.png"></a> 
... 

Portfolio.html :

... 
<!-- filter goes here: --> 
<p id="picker"> 
    <a href="#" id="all" class="current" name="all">All</a> | 
    <a href="#" id="web" class="filter" name="web">Web</a> | 
    <a href="#" id="triD" class="filter" name="triD">3D</a> | 
    <a href="#" id="codes" class="filter" name="codes">Codes</a> | 
    <a href="#" id="video" class="filter" name="video">Video</a> 
</p> 

<!-- my work goes here: --> 
<div class="my-work codes">...</div> 
<div class="my-work web">...</div> 
<div class="my-work triD">...</div> 
<div class="my-work codes">...</div> 
... 

Filter.js :

$(function() 
{ 
    $("#all").click(function(){ 
     $(".my-work").slideDown(); 
     $("#catpicker a").removeClass("current"); 
     $(this).addClass("current"); 
     return false; 
    }); 

    $(".filter").click(function(){ 
     var thisFilter = $(this).attr("id"); 
     $(".my-work").slideUp(); 
     $("."+ thisFilter).slideDown(); 
     $("#catpicker a").removeClass("current"); 
     $(this).addClass("current"); 
     return false; 
    }); 

}); 
+0

이 자바 스크립트 질문이 아닌 HTML의 질문 : 는 portfolio.html에서, 헤더에 모든 스크립트 후에는 다음 스크립트를 추가해야합니다. 당신이 물어 보는 것을하는 방법, 심지어 그것이 가능한지 여부는 전적으로 당신이 사용하는 필터 스크립트가 어떻게 작동하는지에 달려 있습니다. 스크립트를 게시하십시오. – Andrew

+0

filter.js 스크립트 (jQuery로 작성)를 추가했습니다. 현재로서는 portfolio.html에만 포함되어 있습니다. –

답변

0

는 사실 내가 찾은 여기

는 코드입니다 m의 정답 y 질문.

$(document).ready(function() 
{ 
    var type = window.location.hash; 
    //window.location.hash = window.location.hash.replace(type,''); //should be added if you want to remove: ...#class in address bar 
    $(type).trigger('click'); 
});