Showing posts with label iframe. Show all posts
Showing posts with label iframe. Show all posts

Wednesday, May 21, 2014

Sharepoint content cannot be displayed in an IFrame

Share/Save/Bookmark

"This content cannot be displayed in IFrame.To help protect the security of information you enter into this website the publisher of this content does not allow it to be displayed in a frame"

You may be experiencing the above error if you are trying to open a sharepoint page/webpart page in iframe(say ModalDialog) either it could be cross domain or in same domain.

Sharepoint 2013 has added settings to control the source of iframe at site collection level under HTML Field security. This will only allow the current domain/page to accept the content from the specific domain that may be added in the iframe settings. But if you read the top error message, the source domain/page thats rendering in iframe itself is responsible for the behavior not the destination page/domain. So this setting would not resolve the issue. To get rid of the error add the below tag to masterpage/page layout/application page/visual webpart as required..

<WebPartPages:AllowFraming ID="AllowFraming1"runat="server"/>


 Subscribe

Saturday, January 19, 2013

Set width of div part of iframe

Share/Save/Bookmark

How to set the width(in percentage) of the element that is part of iframe?
my first attempt :
$(document).ready(function()
{
$("#divid").css("width","50%");
});
Above script did not work as the script gets triggered immediately after document
loads but before iframe renders
So i tried the below, which did not work for me(in IE 8)
$('iframe').ready()
finally i could run the script on load of iframe with below code
though it failed to set the width property as it was not able to find the div
$('iframe').load(function()
{
   $("#divid").css("width","50%");
}

To access the contents of the iframe use
$("iframe").contents().find("#divid")
Geat!! it could get the div element but could not set the css property as i
was trying to override the css property that already has important tag set
So, how do i set my css property as important through jquery?
Here you go...
$("iframe").load(function () {
        $("iframe").contents().find("#divid").attr("style", "width:50%!important");
    });

voila!!So much learnt today :)


 Subscribe