Sean Williams
Sean Williams

Reputation: 23

Need to remove an image/link from my website

I have been tasked with updating a website. The website is hosted by dexone and they are kind enough (sarcasm) to place an ad at the bottom of all my pages linking back to their sales and services page. The link and image are not editable by me (it uses cm4all as the content manager) and when the site is published they are adding some code to the footer to display their image/link. The image/link code is:

<a style="float:right;" href="http://www.dexone.com/solutions/websites" target="_blank"><img src="http://cm4allfooters.websiteexperts.com/dex/dex.jpg" alt="Dex  website Solutions" title="Dex Website Solutions" height="39" width="180"></a>

I am wondering if using javascript this could be "removed". CSS maybe but I do not see a reference to anything other than img and if I change img to hidden it removes all images on the site and not just this image. Any ideas or suggestions would be greatly appreciated. On a side note I am not a java guy I work in php mostly so if you want to give me an example it will need to be complete or I will screw it up I am sure. Thanks all!

Upvotes: 2

Views: 497

Answers (2)

Mike Corcoran
Mike Corcoran

Reputation: 14565

here is how to do it via straight up javascript:

var elems = document.getElementsByTagName('a');
for (var i=0; i<elems.length; ++i) {
    if (elems[i].href == "http://www.dexone.com/solutions/websites") {
        elems[i].parentNode.removeChild(elems[i]);
    }
}

and using jQuery:

$('a').each(function() {
    if (this.href == "http://www.dexone.com/solutions/websites") {
        $(this).remove();
    }
});

Upvotes: 0

Kevin Boucher
Kevin Boucher

Reputation: 16675

Not with 'Java' but this would probably work in your CSS:

a[href*='//www.dexone.com'] { display: none; }

Yes! Highly recommend you follow Mike Cs advice before implementing this solution.

Upvotes: 1

Related Questions