Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trouble with Javascript link target

Status
Not open for further replies.

roundzny

Programmer
May 23, 2011
2
US
Need help making javascript link open in same iframe
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.


<script>function fbs_click() {u=location.href;t=document.title;window.open(' 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( no-repeat top right; } html .fb_share_button:hover { color:#fff; border-color:#295582; background:#3b5998 url( no-repeat top right; text-decoration:none; } </style> <a rel="nofollow" href=" class="fb_share_button" onClick="top.window.location=' target="_blank" style="text-decoration:none;">Share</a>
 
Hi

Please do not waste our time. Next time
[ul]
[li]do not post minified or otherwise maltreated code[/li]
[li]pointless styles and other decorations[/li]
[/ul]
Beside that, use a text editor with syntax highlighting capability to find the evident syntax errors. Below I colored the strings in your code :
Code:
function fbs_click() {u=location.href;t=document.title;window.open([highlight palegreen]'[URL unfurl="true"]http://www.facebook.com/sharer.php?u=http://www.facebook.com/MyPage&amp;t=MyPage,'[/URL][/highlight palegreen]sharer[highlight palegreen]','[/highlight]toolbar=0,status=0,width=626,height=436[highlight palegreen]');return false;}[/highlight]
Regarding your problem, I think you want to change this :
[tt]onClick="top.window.location='[ignore][/ignore]'"[/tt]
into this :
[tt]onClick="parent.window.location='[ignore][/ignore]'"[/tt]
or maybe this :
[tt]onClick="window.location='[ignore][/ignore]'"[/tt]

However, I not really understood what and where you want to load. If I missed the point, please give more detailed information, including the [tt]iframe[/tt]s and their relations.


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top