首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >innerHTML信息

innerHTML信息
EN

Stack Overflow用户
提问于 2016-12-12 18:53:16
回答 3查看 51关注 0票数 0

我得重新整理一下我的页面。这是生成我的链接的代码的一部分:

代码语言:javascript
复制
$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>';

在屏幕上我看到了这样的东西:

代码语言:javascript
复制
https://localhost/plugin/images/scripts/resize_image.phpm=middle&f=16788&w=390&h=276

我所要做的就是点击选择它。

现在,我需要更改这个部分,以便我的屏幕输出如下:

代码语言:javascript
复制
    {*<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,我的输出就会中断。

因此,为了增加更多的信息:

  1. 这不是重定向。
  2. 我所需要的所有功能都是=>在单击时选择all,这样我可以复制输出。

这个是可能的吗?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-12-14 07:09:17

我设法让它开始工作了。我的问题标题很糟糕,所以我改了。我所需要做的就是改变innerHtml而不是href。不知道我在想什么。这是我的解决办法:

代码语言:javascript
复制
$downloadLinks .= '<li><a onclick="document.getElementById(\'last-crop-resize\').parentElement.style.backgroundColor=\'lightgreen\';document.getElementById(\'last-crop-resize\').innerHTML=\'{*<&#127;img src=&quot;\'+this.href+\'&quot; alt=&quot;&quot; title=&quot;&quot; width=&quot;'.$linkWidth.'&quot; height=&quot;'.$linkHeight.'&quot; vspace=&quot;20&quot; hspace=&quot;20&quot; border=&quot;0&quot; style=&quot;width:'.$linkWidth.';height:'.$linkHeight.';margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;border:0px solid black;&quot; class=&quot;&quot; &#47;>*}\'"; 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>';

产出如下:

代码语言:javascript
复制
{*<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="" />*}

感谢所有想帮忙的人。

票数 0
EN

Stack Overflow用户

发布于 2016-12-12 18:57:04

你的问题不清楚你想要达到什么目的,但我认为你想用一个图像作为链接?

如果是这样的话,这就是你所需要的:

代码语言:javascript
复制
<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>

如果这对我有帮助,请告诉我

票数 0
EN

Stack Overflow用户

发布于 2016-12-12 18:57:53

我不确定,但我想这就是你要找的。

允许在img标记中嵌套a元素。

代码语言:javascript
复制
<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>

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41107582

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档