SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2009
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Have a script.. need it to open links in target-="_blank"

    I need to add [target="_blank"] to the code below but I can't figure it out. Any help would be appreciated.

    Code:
    function showMessengerAd(url, name, message, avatarUrl){
    	$('body').append("<div id=\"messegeradwrapper\"><a href=\"" +url+ "\" id=\"messengeradlink\"><div id=\"messengeradbg\"><div id=\"messengeradavatarwrapper\"><img src=\"" +avatarUrl+ "\" alt=\"\" id=\"messengeradavatar\" /></div><span id=\"messengeradsaystext\">" +name+ " </span><div id=\"messengeradmessagewrapper\"><span id=\"messengeradmesagetext\">" +message+ "</span></div></div></a><a href=\"#\" onclick=\"closeMessengerAd();return false\"><img src=\"" +messengerAdPath+ "messengerad/img/close.png\" alt=\"\" id=\"messengeradclosebutton\" /></a></div>");
    AllTopExchange - Banner Ad Network
    40,000+ Free Impressions When You Join.

    TrinityClicks Best GPT Site EVER! Join Now!

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Try

    Code JavaScript:
    function showMessengerAd(url, name, message, avatarUrl){
        $('body').append("<div id=\"messegeradwrapper\"><a href=\"" +url+ "\" id=\"messengeradlink\"><div id=\"messengeradbg\"><div id=\"messengeradavatarwrapper\"><img src=\"" +avatarUrl+ "\" alt=\"\" id=\"messengeradavatar\" /></div><span id=\"messengeradsaystext\">" +name+ " </span><div id=\"messengeradmessagewrapper\"><span id=\"messengeradmesagetext\">" +message+ "</span></div></div></a><a href=\"#\" onclick=\"closeMessengerAd();return false\"><img src=\"" +messengerAdPath+ "messengerad/img/close.png\" alt=\"\" id=\"messengeradclosebutton\" /></a></div>");
     
        $('#messegeradwrapper').find('a').attr('target', '_blank');
    }

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2009
    Posts
    60
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works great. Thank you!

    Quote Originally Posted by SgtLegend View Post
    Try

    Code JavaScript:
    function showMessengerAd(url, name, message, avatarUrl){
        $('body').append("<div id=\"messegeradwrapper\"><a href=\"" +url+ "\" id=\"messengeradlink\"><div id=\"messengeradbg\"><div id=\"messengeradavatarwrapper\"><img src=\"" +avatarUrl+ "\" alt=\"\" id=\"messengeradavatar\" /></div><span id=\"messengeradsaystext\">" +name+ " </span><div id=\"messengeradmessagewrapper\"><span id=\"messengeradmesagetext\">" +message+ "</span></div></div></a><a href=\"#\" onclick=\"closeMessengerAd();return false\"><img src=\"" +messengerAdPath+ "messengerad/img/close.png\" alt=\"\" id=\"messengeradclosebutton\" /></a></div>");
     
        $('#messegeradwrapper').find('a').attr('target', '_blank');
    }
    AllTopExchange - Banner Ad Network
    40,000+ Free Impressions When You Join.

    TrinityClicks Best GPT Site EVER! Join Now!

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,192
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Your welcome


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •