开发者

strange link code in jquery -- adding target attributes

开发者 https://www.devze.com 2023-03-27 09:35 出处:网络
Hours have already been spent because of my own programmer pride. The coding is calling information for the links from earlier input in the html. The first if then statement below is for the links on

Hours have already been spent because of my own programmer pride. The coding is calling information for the links from earlier input in the html. The first if then statement below is for the links on the "more" buttons in a rotator. The second is for the links on the corresponding thumbnails. After searching this site and finding similar posts, I found that none of them addressed targets for this type of link input. I just need a _parent target on them, that's all. Is there someway to incorporate "attr" to get a target _parent for the links in this type of code? Any help would be hugely appreciated.

if(! encDisableTextsAll && encEnableFooter)
{
    for(i=0; i<encNumOfImages; i++)
    {
        $(".footerTitle:eq(" + i + ")").html(encBannerTexts[i][0]);
        if(encEnableDescription) $(".footerDesc:eq(" + i + ")").html(encBan开发者_开发问答nerTexts[i][1]);
        if(encBannerTexts[i][2] != "" & encEnableReadMore)
        {
            $(".footerLink:eq(" + i + ")").html("<div class='bttnMore'><a href='" + encBannerTexts[i][2] + "'>&nbsp;</a></div>");
        }
    } 
}
if(encEnableThumbImageLink && encEnableFooter)
{
    for(i=0; i<encNumOfImages; i++)
    {
        link = encBannerTexts[i][2];
        $("#thumbDiv_" + i).attr("onclick", "window.location.href='" + link + "'")

    }
}

// supposed link call
if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] &&      elem ["on"+type].apply( elem, data ) === false )
        event.result = false;


$(".footerLink:eq(" + i + ")").html("<div class='bttnMore'><a href='" + encBannerTexts[i][2] + "'>&nbsp;</a></div>");

should be

$(".footerLink:eq(" + i + ")").html("<div class='bttnMore'><a target=\"_parent\" href='" + encBannerTexts[i][2] + "'>&nbsp;</a></div>");

and

window.location.href

should be

top.window.location.href
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号