1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Need help with simple javascript code

Discussion in 'General Programming Chat' started by freechong, Dec 16, 2011.

  1. freechong

    freechong Newbie

    Joined:
    May 9, 2009
    Messages:
    35
    Likes Received:
    1
    Hi,

    I am trying to make an image do two separate events in a wordpress post. The first, opens up an inpage popup using a plugin called Thickbox Content with a facebook share button. At the same time, a new window opens up and goes to my ad site. Can anyone help me fix this script? Thanks!


    Code:
    <script type="text/javascript">
    function open_win() 
    {
    [thkBC height="225" width="490" anchortext="mysite" title="Share Us With Your Friends!"  url="mysite.com/share.php" type="iframe" html_wrap="p"];
    
    window.open("mysite.com/ad.php" ta);
    }
    </script>
    
    <form>
    <a onclick="open_win()"><img src="mysite.com/myadpic"></a>
    </form>
     
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    You can't put a shortcode on JS/HTML code :)
     
    • Thanks Thanks x 1
  3. freechong

    freechong Newbie

    Joined:
    May 9, 2009
    Messages:
    35
    Likes Received:
    1
    Oh okay so there is no possible way to make an image load that code and open a window to an ad?
     
  4. casius

    casius Junior Member

    Joined:
    Apr 18, 2010
    Messages:
    186
    Likes Received:
    20
    Home Page:
    yes it is possible, but I would recommend to use wordpress plugins that are designed for this thing instead of putting them to your wordpress loop.
     
    • Thanks Thanks x 1
  5. freechong

    freechong Newbie

    Joined:
    May 9, 2009
    Messages:
    35
    Likes Received:
    1
    Can you suggest any plugins that might do the trick? I would much rather do that.
     
  6. ab320012

    ab320012 Newbie

    Joined:
    Mar 20, 2016
    Messages:
    8
    Likes Received:
    0
    Hey if you put this in your function it should create an iframe with the specs you have in the shortcode and append it to the body. if you want something to cover the rest of the screen you're going to need another element (should probably style it better as well), let me know if you need more help.

    Code:
    var popup = document.createElement('iframe');
    popup.height = 225;
    popup.width = 490;
    popup.src = "siteUrl";
    document.body.appendChild(popup);
    
     
  7. PHPInjected

    PHPInjected Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 25, 2014
    Messages:
    2,065
    Likes Received:
    1,714
    Occupation:
    100% Unique Content Writer
    Location:
    Overriding Methods
    Home Page:
    While we appreciate your insight into a JS question, this is a 5 year old thread.
     
  8. BrianKu

    BrianKu Newbie

    Joined:
    May 1, 2016
    Messages:
    6
    Likes Received:
    0
    PHPÄ°njected ;);)