Can I change the link of a category thumb?
mk12345
Registered Users Posts: 63 Big grins
I would like to click a thumb or link of a category on my homepage, and have that open a new browser with a different website. How can I get accces to the href of a category thumb on my homepage?
0
Comments
Works nicely. I can now click on the thumb or the caption, and it will open a new browser showing the specified site.
/************************************************************************************************/
/********************** CODE TO REDIRECT THUMB AND IT's LINK ************************************/
/************************************************************************************************/
var sLinkIDPrefix = '<LAST to override want I that link of part>';
var aLinkInfo = new Array();
aLinkInfo[0] = '<MY image>|<LINK to want redirect i>';
function Redirect2URL(e)
{
var oSourceElement = (document.all?window.event.srcElement:e.target);
// Check element type, if not a hyperlink or image do nothing
if ((oSourceElement.src) || (oSourceElement.href))
{
// Check hyperlink for ID Prefix
if(oSourceElement.href)
{
if ((oSourceElement.href.indexOf(sLinkIDPrefix) > 0) || (oSourceElement.href.indexOf('<MY image>')))
{
// Reassign Href value to array value
if((oSourceElement.src) && (oSourceElement.src.indexOf('<MY image>')))
{
oSourceElement.parentElement.target='_new';
oSourceElement.parentElement.href='<LINK to want redirect i>';
}
else
{
oSourceElement.target='_new';
oSourceElement.href='<LINK to want redirect i>';
}
}
}
}
}
//Create OnClick Event Listener
document.onclick = Redirect2URL;
Portfolio • Workshops • Facebook • Twitter
function Redirect2URL(e)
{
var oSourceElement = (document.all?window.event.srcElement:e.target);
// Check element type, if not a hyperlink or image do nothing
if ((oSourceElement.src) || (oSourceElement.href))
{
if ((oSourceElement.href) && (oSourceElement.href.indexOf('MyUniqueCaptionLinkString') > 0)) // Hyperlink
{
oSourceElement.target='_blank';
oSourceElement.href='http://www.MyNewLink.com';
}
else if (oSourceElement.parentNode.href.indexOf('MyUniqueCaptionLinkString')) // Image
{
oSourceElement.parentNode.target='_blank';
oSourceElement.parentNode.href='http://www.MyNewLink.com';
}
}
}
//Create OnClick Event Listener
document.onclick = Redirect2URL;
Do you have a gallery where we could see it working?
</your></any></your></any>
smugmug nickname: mpmcleod
http://www.michaelmcleod.com/