从外部html文件执行链接
我有2个html文件:从外部html文件执行链接,html,filter,hyperlink,Html,Filter,Hyperlink,我有2个html文件: index.html portfolio.html 在portfolio.html中,我有4类工作:web、3d、代码和视频。此外,我还包括了一个过滤器脚本,它只显示所选类别的工作和它的工作 在index.html中,我需要有指向我的投资组合的每个类别的链接,但我不知道如何做到这一点 代码如下: Index.html: ... <a href="portfolio.html#web"><img src="img/web.png"></a&
- index.html
- portfolio.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中,在标题中的所有脚本之后,应添加以下脚本:
$(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');
});
这是一个javascript问题,不是HTML问题。如何执行您要求的操作,或者是否可能,完全取决于您使用的筛选脚本的工作方式。请发布脚本。我已经添加了filter.js脚本(它是用jQuery编写的)。目前它只包含在portfolio.html中
$(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;
});
});
$(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');
});