Mobile browser-document is not loading in an iframe

199 views
Skip to first unread message

Jayaseelan A

unread,
May 24, 2016, 12:22:34 PM5/24/16
to PDFTron WebViewer
Hi all
we are having problem in mobile browser and using latest WebViewer to load the XOD document .
loading in an iframe on diffrent domain than the page domain.
but i got this error:
Uncaught SecurityError: Blocked a frame with origin "https://domaine1.com" from accessing a frame with origin "https://domaine2.com". Protocols, domains, and ports must match. : CoreControls.js:278 and ControlUtils.js:134

Note : document isn't loading in mobile web browser,but it is working as expected on desktop browser.

i have attached screenshot for your reference.
 
Can you please help me to find a solution.

Thanks
Screen Shot 2016-05-23.png

sbi

unread,
May 25, 2016, 12:36:15 PM5/25/16
to PDFTron WebViewer
I also noticed that the WebViewer tries to call some variables/methods of the parent-Frame (mobile AND desktop) which is not possible in a Cross-Domain multi-frame environment.
It would be desirable if this behaviour could be improved.

We used a workaround by embedding the viewer in another iframe with origin domaine1.com on desktop and using theredirect functionality on mobile devides.

Anatoly Kudrevatukh

unread,
May 25, 2016, 3:03:09 PM5/25/16
to PDFTron WebViewer
Thank you for reporting the problem. This is not the intended behavior and should be fixed in the next official release.

Jayaseelan A

unread,
May 27, 2016, 12:52:08 PM5/27/16
to PDFTron WebViewer
Hi,
Thank you for your response.

We are facing this issue in production site.
Can you send me the custom build in order to fix this issue?

Thanks

Matt Parizeau

unread,
Jun 8, 2016, 5:16:53 PM6/8/16
to PDFTron WebViewer
To fix the issue you should just need to update ControlUtils.js and WebViewer.min.js. I've attached the updated files for you.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
updatedFiles.zip

Matt Parizeau

unread,
Jul 29, 2016, 3:09:16 PM7/29/16
to PDFTron WebViewer
This build has an additional fix for cross domain issues in WebViewer: http://www.pdftron.com/ID-zJWLuhTffd3c/WebViewer/WebViewer_2.2.0.47800.zip

Jayaseelan A

unread,
Aug 2, 2016, 1:26:53 PM8/2/16
to PDFTron WebViewer
Matt,
Thanks for your reply.

We tested and worked.

sbi

unread,
Sep 7, 2016, 3:45:19 AM9/7/16
to pdfnet-w...@googlegroups.com
Is the fix also included in the new 2.2.1 release?

Matt Parizeau

unread,
Sep 7, 2016, 1:41:19 PM9/7/16
to PDFTron WebViewer
Yes it should be fixed in 2.2.1. If you're having any issues with it then let us know.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

sbi

unread,
Jun 7, 2017, 4:39:52 AM6/7/17
to PDFTron WebViewer
Hi Matt,

we still have some issues with this.
If we for example want to load the WebViewer on dynamic.domain.com and the resources are located at static.domain.com we get an error in Line 403:

me.instance = this.contentWindow.readerControl;

This is caused by the fact that the origins of the frame the WebViewer.js is loaded into and the iframe created by the WebViewer are different.
Is there something you could do about this?

We currently "solve" this by creating a iframe ourselves with origin static.domain.com and load a relatively basic HTML there that loads the WebViewer.
This is not optimal in many ways:

- We have to load jQuery again in this iframe, as WebViewer.js needs jQuery to load
- There are two nested iframes
- Every communication to the outer window (we use eventhandlers and postMessage for this) has to be tunneled through the extra iframe
- Config/custom data has to be tunneled through the iframe

A real working solution would be very welcomed.

Justin Jung

unread,
Jun 7, 2017, 4:38:18 PM6/7/17
to PDFTron WebViewer on behalf of sbi
You could modify WebViewer.js and ReaderControl.js to send messages back and forth using postMessage instead of accessing readerControl directly from the iframe window.
We will consider doing something like this for a future version.

Justin Jung
Software Developer
PDFTron Systems inc.

sbi

unread,
Jun 8, 2017, 11:59:13 AM6/8/17
to PDFTron WebViewer
Hi Justin,

thanks for the fast response.

I would like to avoid changing the WebViewer JS files directly as it destroys upgradeability and maintainability.
I investigated the code block around line 403 a little more and it seems that the registered callback to $rcFrame.load is causing the issue.
It seems like this is your way to make the readerControl object accessible from outside of the WebViewer iframe.

As we don't need this functionality would it be possible (and a quicker solution as a complete postMessage rewrite) to disable this binding with an option when calling new PDFTron.WebViewer(options, viewerElement) ?

Justin Jung

unread,
Jun 9, 2017, 7:32:24 PM6/9/17
to PDFTron WebViewer on behalf of sbi
Yes that could work too and it's something we can consider.
For now, it would be best for you to modify WebViewer.js.

Justin Jung
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages