索引.html
<a href="product.html#category1">category 1</a>
<a href="product.html#category2">category 2</a>
<a href="product.html#category3">category 3</a>
产品.html
$(document).ready(function(){
var item = toLowerCase((document.location.hash)).replace('#','');
if(/category[1-3]/i.test(item)){
changeIframe(item);
}else{
changeIframe(defaultitem);
}
});
如果您使用的是 php
索引.html
<a href="product.html?item=category1">category 1</a>
<a href="product.html?item=category2">category 2</a>
<a href="product.html?item=category3">category 3</a>
产品.html
<script>
<?php
if(isset($_GET['item']) && preg_match("/category[1-3]/", $_GET['item'])){
echo "changeIframe(" . $_GET['item'] .");";
}else{
echo "changeIframe(defaultitem);";
}
</script>