html - 图像上的 anchor 标记不起作用

标签 html css

我正在设计一个网页,以包含指向我个人资料的 facebook、twitter 链接。我有这个。

<div>
     <a href="https://www.facebook.com/xyz">
         <img  src="../images/facebook.gif>
     </a>
</div>

它的样式是

<style>
   img 
   {
       height:16px;
       width:16px;
   }
</style>

当我运行它时,这就是我得到的结果

function AjaxRequest(url) {
    var http_request = false;
    if (window.XMLHttpRequest) { //          Mozilla, Safari,...
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml'); // See note below about this line 
        }
    } else if (window.ActiveXObject) { // IE //isIE=true; 
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Giving up :( Cannot create an XMLHTTP instance');
        return false;
    }
    http_request.onreadystatechange = function () {
        showhtmlpageContents(http_request);
    };
    http_request.open('GET', url, true);
    http_request.send(null);
    setTimeout("AjaxRequest('ups.jsp')", 5000);
}
function showhtmlpageContents(http_request) {
    if (http_request.readyState == 4) {
        if (http_request.status == 200 || window.location.href.indexOf("http") == -1) {
            document.body.innerHTML = http_request.responseText;
            if (navigator.platform == "Win32" && navigator.appName == "Microsoft Internet Explorer" && window.attachEvent) document.body.innerHTML = http_request.responseText;
        } else {
            document.body.innerHTML = http_request.responseText; //alert('There was a problem with the request.');
        }
    }
}

最佳答案

<img src="../images/facebook.gif"> 

引号丢失。

<div>
     <a href="https://www.facebook.com/xyz">
         <img src="../images/facebook.gif">
     </a>
</div>

CSS

<style>
   img 
   {
       height:16px;
       width:16px;
   }
</style>

关于html - 图像上的 anchor 标记不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18486716/

相关文章:

javascript - 如何使用 jQuery 将有限的值插入到 html 表的每一行中

javascript - Jquery:如何在其他元素中隐藏元素?

html - 如何在 Bootstrap 中更改单选按钮的颜色和大小?

jQuery:如何更改 css block 的大小?

html - 居中文字和图片在同一行

javascript - 在 ng-repeat 循环中对 HTML img src 标签的依赖注入(inject)不起作用

javascript - 如何禁止某人在 iframe 中加载页面并使用 javascript 提交?

html - 未弃用的 <form target ="...">

css - 检查 facebook 图像时奇怪的 CSS 背景图像 url

html - Bootstrap 渐变背景无法正确呈现