[HELP] Executing this twitter share from .html(""); function. Probably easy?

Discussion in 'JavaScript' started by Damdomy, Jan 26, 2012.

  1. #1
    Hi,


    I've been coding my ass off today. My brain can't think anymore. Before i go to sleep i though i would post this here hopefully someone will help me.

    I have this code:
    $('#message').html("<div class='ui-widget'><div class='ui-state-highlight ui-corner-all' style='margin-top: 20px; padding: 0 .7em;'><p><span class='ui-icon ui-icon-info' style='float: left; margin-right: .3em;'></span><strong>Success!</strong> Your URL has been shortened.</p><br/><br/>");
    Code (markup):
    I need help putting a twitter code which is:
    
    Share it: window.open("<a href='https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Fmub.me%2Fmub.me&source=Mub.me&text=&url=http%3A%2F%2Fblablabla.com'><img src='images/twitter.png'")>
    
    Code (markup):
    How do i integrate the twitter code so it would be inside this message without any errors.

    If you have a better alternative method. Please also post below :)

    Thanks very much.
     
    Damdomy, Jan 26, 2012 IP
  2. awood969

    awood969 Member

    Messages:
    186
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    40
    #2
    You need to wrap script tags around it, however javascript tries to deal with HTML itself (which is fails badly at doing with the </script> tag), so add everything into the .html(); function except for </script> and then use .append('<'); and then .append('\script'); and then finally .append('>');

    It seems ridiculous but its the only way I've ever found to get it to work. You may possibly need to repeat for the initial <script> tag.

    Thanks
    Andrew
     
    awood969, Feb 1, 2012 IP