我得重新整理一下我的页面。这是生成我的链接的代码的一部分:
$downloadLinks .= '<li><a onclick="document.getElementById(\'last-crop-resize\').parentElement.style.backgroundColor=\'lightgreen\';document.getElementById(\'last-crop-resize\').innerHTML=this.href" target="_blank" href="'._CONFIG_SITE_PROTOCOL . '://' . file::getFileDomainAndPath($file->id, $file->serverId, true) . '/' . PLUGIN_DIRECTORY_NAME.'/images/scripts/resize_image.php?m=middle&f='.(int) $file->id.'&w='.$linkWidth.'&h='.$linkHeight.'"><i class="entypo-right"></i>JPG '.$linkWidth.' x '.$linkHeight.' px</a> </li>';在屏幕上我看到了这样的东西:
https://localhost/plugin/images/scripts/resize_image.phpm=middle&f=16788&w=390&h=276我所要做的就是点击选择它。
现在,我需要更改这个部分,以便我的屏幕输出如下:
{*<img src="https://localhost/plugin/images/scripts/resize_image.php
m=middle&f=16788&w=390&h=276"
alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
margin-left:0px;margin-right:0px;border:0px solid black;" class="" />*}我尝试使用ASCII在innerHTML中转义,但是一旦我尝试放置<img,我的输出就会中断。
因此,为了增加更多的信息:
这个是可能的吗?
发布于 2016-12-14 07:09:17
我设法让它开始工作了。我的问题标题很糟糕,所以我改了。我所需要做的就是改变innerHtml而不是href。不知道我在想什么。这是我的解决办法:
$downloadLinks .= '<li><a onclick="document.getElementById(\'last-crop-resize\').parentElement.style.backgroundColor=\'lightgreen\';document.getElementById(\'last-crop-resize\').innerHTML=\'{*<img src="\'+this.href+\'" alt="" title="" width="'.$linkWidth.'" height="'.$linkHeight.'" vspace="20" hspace="20" border="0" style="width:'.$linkWidth.';height:'.$linkHeight.';margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;border:0px solid black;" class="" />*}\'"; target="_blank" href="'._CONFIG_SITE_PROTOCOL . '://' . file::getFileDomainAndPath($file->id, $file->serverId, true) . '/' . PLUGIN_DIRECTORY_NAME.'/images/scripts/resize_image.php?m=middle&f='.(int) $file->id.'&w='.$linkWidth.'&h='.$linkHeight.'"><i class="entypo-right"></i>JPG '.$linkWidth.' x '.$linkHeight.' px </a> </li>';产出如下:
{*<img src="https://localhost/plugin/images/scripts/resize_image.php
m=middle&f=16788&w=390&h=276"
alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
margin-left:0px;margin-right:0px;border:0px solid black;" class="" />*}感谢所有想帮忙的人。
发布于 2016-12-12 18:57:04
你的问题不清楚你想要达到什么目的,但我认为你想用一个图像作为链接?
如果是这样的话,这就是你所需要的:
<a href="https://localhost/plugin/images/scripts/resize_image.php
m=middle&f=16788&w=390&h=276">
<img src="https://localhost/plugin/images/scripts/resize_image.php
m=middle&f=16788&w=390&h=276"
alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
margin-left:0px;margin-right:0px;border:0px solid black;" class="" />
</a>如果这对我有帮助,请告诉我
发布于 2016-12-12 18:57:53
我不确定,但我想这就是你要找的。
允许在img标记中嵌套a元素。
<a href="https://localhost/plugin/images/scripts/resize_image.php?m=middle&f=16788&w=390&h=276"> <img src="https://localhost/plugin/images/scripts/resize_image.php?m=middle&f=16788&w=390&h=276"
alt="" title="" width="390" height="276" vspace="20" hspace="20" border="0"
style="width:390px;height:276px;margin-top:0px;margin-bottom:0px;
margin-left:0px;margin-right:0px;border:0px solid black;" class="" /></a>
https://stackoverflow.com/questions/41107582
复制相似问题