Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Trying to hide certain div's when embedded, having trouble can anyone help?

I'm not a coder at all and so if I've gone about this completely wrong I would really appreciate a push in the right direction.

So basically I'm going to have my Q&A forum presented in full on my domain but also I'm going to embed it on a facebook page and when embedded I want only the "content" div shown (and centered). This is what I've cobbled together (which I cannot get to work):

I made a plugin to inject javascript in the header and run in on body onload:
<?php
// Define the plugin:
$PluginInfo['fbembed'] = array(
'Description' => 'My custom/hacked javascript to render view for fb embed.',
'Version' => '1.0',
'Author' => "James McIntyre",
'AuthorEmail' => 'james.mcintyre@facebook.com',
'AuthorUrl' => 'fb.me/james.mcintyre'
);

$Head->Addscript('js/fbembed.js');

$Context->BodyAttributes = 'onload="javascript:iframed()"';

?>

When I try to enable the plugin I get this error msg:
"Parse error: syntax error, unexpected T_CONCAT_EQUAL in /answers/plugins/fbembed/default.php on line 13"

This is the javascript file I'm pointing to:



//below is code i grabbed for toggle-hiding div
function toggleLayer( whichLayer )
{
var elem, vis;
if( document.getElementById ) // this is the way the standards work
elem = document.getElementById( whichLayer );
else if( document.all ) // this is the way old msie versions work
elem = document.all[whichLayer];
else if( document.layers ) // this is the way nn4 works
elem = document.layers[whichLayer];
vis = elem.style;
// if the style.display value is blank we try to figure it out here
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

//if in iframe run toggle layer (hide divs)
function iframed()
{
if (top !== self)
{
toggleLayer('Banner');
toggleLayer('Panel');
//this should modify css to center the "content" div
document.getElementById('content').style.float = 'none';
document.getElementById('content').style.margin-left = 'auto';
document.getElementById('content').style.margin-right = 'auto';
}
}
Sign In or Register to comment.