简体   繁体   中英

Anchor tag on image not working

I am designing a web-page to include facebook, twitter links to my profile. I have this.

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

And the styling for it is

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

When I run it, this is what I get

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"> 

Quotes were missing.

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

CSS

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

Try like this

<a  style="display:block; href ="https://www.facebook.com/xyz">
         <img  src = "../images/facebook.gif">
     </a>

Try this.

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

Css:

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

Try this:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM