Skip to Content
avatar image
Former Member

Iframe in sapui5 xml views

Hi all,

i am using iframe inside my XML views , i need to change the src attributes of the iframe dynamically,

in that i am using google doc viewer

while i am trying to set src of iframe its giving 'SAMEORIGIN' issue,

but if we fixed the same url then it is working fine.

below code is for iframe in xml view,

<html:iframe target='_top' src="https://docs.google.com/viewer?url=http%3A%2F%2Ftsddev.cname.net%2Fecomm%2FAGR0000000005.pdf&embedded=true" id ="attachmentframe" height="100%" width="100%">

</html:iframe>

if user clicks on a button i am trying to change the src of iframe as follows

document.getElementById("__xmlview4--attachmentframe").src = pathFormed

if we are placing the same url in pathFormed varaibale it will giving error.

can you any one help .

Thanks

Kotesh.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Oct 27, 2015 at 04:54 AM

    Hi Kotesh,

    Try like this:

    var oFrame = sap.ui.getCore().byId("__xmlview4--attachmentframe"); //Get Hold of iframe
    var oAttributes = oFrame._xContent.attributes; //iframe Attributes
    var oValues = {"target": oAttributes[0].value, "src":oAttributes[1].value, "id":oAttributes[2].value, "height":oAttributes[3].value, "width": oAttributes[4].value}; //Attribute Values
    alert(JSON.stringify(oValues)); //Alert the Attributes
    
    
    

    Check the sample here: Plunker

    Once you got hold of the attributes, I hope you know how to change them.

    Regards,

    Sai Vellanki.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 27, 2015 at 06:13 AM

    Hi Kotesh,

    I hope this will be helpful to you.

    SAPUI5 PDF Display

    Thanks,

    Karthik A

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2015 at 07:25 AM

    Hi Karthik,

    if i am trying above example i am getting error like below

    "in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'."

    if we are directly given the url of the iframe it is working fine otherwise it's getting same origin error.

    Thanks

    Kotesh.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2015 at 12:23 PM

    Hi all,

    Here is my code for iFrame,

    in XML View

    <html:iframe target='_top' src="" id ="attachmentframe" height="100%" width="100%">

    </html:iframe>

    in Controller i tried in two ways                        

    var pdfUrl = "https://docs.google.com/viewer?url=http%3A%2F%2Fvtxdev.Pivog.net%2Fecomm%2F3M%2F0000006673%2Fdocumnt.txt&embedded=true";    // $('#'+this.getView().byId('attachmentframe').sId).attr("src",pdfUrl);    document.getElementById("__xmlview4--attachmentframe").src = pdfUrl;

                  

    after this if we are checking the src of the iframe it is getting empty and as well as getting SAME-ORIGIN" error

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 27, 2015 at 12:23 PM

    Hi all,

    Here is my code for iFrame,

    in XML View

    <html:iframe target='_top' src="" id ="attachmentframe" height="100%" width="100%">

    </html:iframe>

    in Controller i tried in two ways                        

    var pdfUrl = "https://docs.google.com/viewer?url=http%3A%2F%2Fvtxdev.Pivog.net%2Fecomm%2F3M%2F0000006673%2Fdocumnt.txt&embedded=true";    // $('#'+this.getView().byId('attachmentframe').sId).attr("src",pdfUrl);    document.getElementById("__xmlview4--attachmentframe").src = pdfUrl;

                  

    after this if we are checking the src of the iframe it is getting empty and as well as getting SAME-ORIGIN" rrror

    Add comment
    10|10000 characters needed characters exceeded