Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 27, 2015 at 06:13 AM

    Hi Kotesh,

    I hope this will be helpful to you.

    SAPUI5 PDF Display

    Thanks,

    Karthik A

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.