scribd set page not working

313 Views Asked by At

I am using scribd to display pdf. By clicking on the Page 3,Middle,End links the corresponding pages should load. But the pages are not loading properly. And in FF i am not getting any errors. But in chrome console i am getting this error. Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://www.scribd.com') does not match the recipient window's origin ('https://www.scribd.com'). Can anyone help me out in this?

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

  <title>Scribd Javascript API Demo</title>

  <script type="text/javascript" src='https://www.scribd.com/javascripts/scribd_api.js'></script>
</head>

<body>
  <div id="container">
    <div id='col1'>
      <div id='embedded_doc'><a href='https://www.scribd.com'>Scribd</a></div>
    </div>

    <div id='col2'>
      <h2 id="header"> Loading Document... </h2><br/>
      <span id="author"></span>
      <div id="bookmarks">
        <h4>Bookmarks</h4>
        <ul>
          <li><a href="javascript:goToPage(3);">Page 3</a></li>
          <li><a href="javascript:goToMiddle();">Middle</a></li>
          <li><a href="javascript:goToEnd();">End</a></li>
        </ul>
      </div>
      <div id="comment"></div>
    </div>
    <div class="clearfix">&nbsp;</div>

  </div>


  <script type="text/javascript">


      // Data



      // Instantiate iPaper
      var scribd_doc = scribd.Document.getDoc(2520449, 'key-1127428tb3rbejns9bhr');


      // Parameters
      scribd_doc.addParam('height', 420);
      scribd_doc.addParam('width', 530);
      scribd_doc.addParam('auto_size', true);
      scribd_doc.addParam('mode', 'slideshow');
      scribd_doc.addParam('jsapi_version', 2);     

      // Write the instance
      scribd_doc.write('embedded_doc');

      // Bookmark Helpers
      var goToPage = function(page) { alert(scribd_doc.api.getPageCount());
        if (scribd_doc.api){ 
          scribd_doc.api.setPage(3);
        }
      }

      var goToMiddle = function() {
        if (scribd_doc.api){
          goToPage( Math.floor(scribd_doc.api.getPageCount()/2) );
        }
      }

      var goToEnd = function() {
        if (scribd_doc.api) {
          goToPage(scribd_doc.api.getPageCount());
        }
      }
  </script>
  View Source and you'll see that this is all dynamically generated using the Scribd Javascript API.
</body>
</html>
1

There are 1 best solutions below

0
On

I fixed this issue by downloaded the scribd_api.js file and modified the path to https in js. And now the set page is working without any errors.