Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在“新建”选项卡中打开缩略图_Javascript_Jquery_Html - Fatal编程技术网

Javascript 在“新建”选项卡中打开缩略图

Javascript 在“新建”选项卡中打开缩略图,javascript,jquery,html,Javascript,Jquery,Html,我是新来的,我的大脑在燃烧 我的问题是我访问了一个网站lemonx.biz 如你所见,我在那里制作了4个框架,展示了zara hermes和puma的小鞋子 当用户单击文件夹images/zara/thumbnals/1.png中显示zara puma和hermes shoes的小缩略图时,将打开一个新窗口选项卡,使用html javascript或jquery在div中显示来自images/zara/1.pngimage的较大版本的缩略图。使用href指向图像的较大版本和目标=“\u blan

我是新来的,我的大脑在燃烧

我的问题是我访问了一个网站lemonx.biz

如你所见,我在那里制作了4个框架,展示了zara hermes和puma的小鞋子


当用户单击文件夹
images/zara/thumbnals/1.png
中显示zara puma和hermes shoes的小缩略图时,将打开一个新窗口选项卡,使用html javascript或jquery在div中显示来自
images/zara/1.png
image的较大版本的缩略图。

使用
href
指向图像的较大版本和
目标=“\u blank”

编辑:根据您更新的说明

不要直接链接到图像,而是链接到
next.html#name_of_image.jpg
。然后,在加载next.html时,执行javascript以使用适当的图像填充目标div

e、 g:


window.onload=函数()
{
if(location.hash)//仅当存在实际哈希值时才执行此操作。
{
var imgPath='path/to/images/directory/';//构建到images目录的路径。
var imgName=location.hash.substring(1);//从哈希中获取图像的名称并删除#。
document.getElementById('target_img')。src=imgPath+imgName;//使用实际图像的路径和名称更新占位符图像的src。
document.getElementById('target_img')。style.display='inline';//现在它有了一个有效的源代码,将其显示给查看器。
}
}

我已经做到了,但我有一个页面next.html在这个页面中我有一个div我想在特定div中打开next.html中单击的缩略图亲爱的aaron,你的代码将要做的是我有100张图片,所有图片我都必须附加一个html,在每个html中我都必须嵌入javascript代码,这不是我想要的解决方案需要一些动态的东西吗?您有一个html文件,它读取由上一页上生成缩略图的脚本动态生成的哈希值。
<!--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>