I have an ASP.NET C# application. I am displaying a PDF file at a specific page inside an iframe. I need to display a specific page of PDF based on a text box value. How can I achieve this ?
The iframe code looks like this:
<iframe runat="server" id="lobjPDFObj" height="600" width="800" > </iframe>
and following is the the details of the text box
<asp:TextBox ID="txtTo" runat="server" Text="1" class="page_txtbox" onfocus="synchronizePDF(this);" ></asp:TextBox>
Details of javascript function
function synchronizePDF(Field) {
//parent.document.getElementById('lobjPDFObj').setCurrentPage(Field.value);
var childiFrame = parent.document.getElementById('lobjPDFObj');
var URL = childiFrame.contentWindow.location.href;
//var URL = childiFrame.src;
var pos = URL.indexOf('#page');
if (pos < 0) pos = URL.length;
var result = URL.substring(0, pos);
if (URL != 'about:blank') {
result += '#page=' + Field.value;
}
childiFrame.contentWindow.location.reload(true);
childiFrame.contentWindow.location.href = result;
//childiFrame.src = result;
//parent.document.getElementById('lobjPDFObj').setAttribute("src", result);
}
But this is not working. It is giving error at "childiFrame.contentWindow.location.href" as The frame requesting access has a protocol of "http", the frame being accessed has a protocol of "https". Protocols must match.
How can i get rid of the error? And i am passing page no as a paramter in the url. How can i show the new page without refreshing entire content?