用指向圖像放大版和target="_blank"
的href
將錨定標記中的圖像包裹起來。
編輯:根據您的更新說明。
不直接鏈接到圖像,鏈接到next.html#name_of_image.jpg
。然後,在加載next.html時,執行javascript以使用適當的圖像填充目標div。
如:
<!--Include a placeholder image in your HTML in the target div...-->
<div id="target_div">
<img id="target_img" style="display: none;" src=""/>
</div>
<!--...And populate it on page load with Javascript.-->
<script type="text/javascript">
window.onload = function()
{
if (location.hash) //Only do this if there's an actual hash value.
{
var imgPath = 'path/to/images/directory/'; //Build the path to the images directory.
var imgName = location.hash.substring(1); //Get the name of the image from the hash and remove the #.
document.getElementById('target_img').src = imgPath+imgName; //Update the src of the placeholder image with the path and name of the real one.
document.getElementById('target_img').style.display = 'inline'; //Now that it has a valid source, reveal it to the viewer.
}
}
</script>
我這樣做,它的作品,但我在此頁面中我有一個div我想在next.html在特定的div – sajid 2011-12-22 09:44:15
打開點擊縮略圖頁面next.html @ sajid啊,好的。沒有汗水。檢查我上面編輯的答案。 – Aaron 2011-12-22 20:37:20
親愛的阿倫你的代碼會做的是,我有100的圖片和所有的圖片,我必須附上一個HTML,並在每一個HTML我必須嵌入JavaScript代碼這不是我需要動態的一些東西的解決方案 – sajid 2011-12-23 04:35:29