Need help making javascript link open in same iframe

Discussion in 'JavaScript' started by cheftom, May 23, 2011.

  1. #1
    I am trying to use the javascript below on my facebook page iframe...

    The javascript displays a share button on my page.... when clicked... it should open the share dialogue in a new window (which it does correctly) Also when clicked I want it to load a new page into my iframe within facebook....(this does not work properly)

    when I click, it opens the new page by itself in the same window...but it does not display it within facebook Like I want it to.

    What needs to be changed in my code ?

    <script>function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u=http://www.facebook.com/MyPage&t=MyPage,'sharer','toolbar=0,status=0,width=626,height=436');return false;}</script><style> html .fb_share_button { display: -moz-inline-block; display:inline-block; padding:1px 20px 0 5px; height:15px; border:1px solid #d8dfea; background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; } html .fb_share_button:hover { color:#fff; border-color:#295582; background:#3b5998 url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981) no-repeat top right; text-decoration:none; } </style> <a rel="nofollow" href="http://www.facebook.com/share.php?u=http://www.facebook.com/MYFACEBOOKPAGE" class="fb_share_button" onClick="top.window.location='http://NEWPAGEIWANTTOLOAD'" target="_blank" style="text-decoration:none;">Share</a>
    Code (markup):
     
    cheftom, May 23, 2011 IP
  2. Voynex

    Voynex Peon

    Messages:
    31
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please form the code properly. It's pretty hard to read it. Also window.open always opens the link in the new window. To open it in iframe you need to get it's document object first.
     
    Voynex, May 24, 2011 IP