473,574 Members | 2,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamic IFrame Creation Caching Problem

28 New Member
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with the html page. But if I try to navigate to another pdf in the IFRAME then no caching occurs. Is the problem in the IFRAME reloading instead of just refreshing the pdf?

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type="text/javascript">
  3. var pageNo;
  4. var nav;
  5. var iframe;
  6. var embed;
  7. pageNo = 1;
  9. var embed = "<EMBED src=/Catalog/Page" + pageNo + ".pdf scrollbar=1&amp;messages=0&amp;statusbar=0&amp;navpanes=0 width=600 height=650></EMBED>";
  11. function makeIframe() {
  12. iframe = document.createElement("IFRAME");
  13. iframe.src = "javascript:'<HTML><HEAD>";
  14. iframe.src += "<TITLE>Dynamic IFrame</TITLE>";
  15. iframe.src += '</HEAD><BODY>';
  16. iframe.src += '<FORM method=get action=dummy.php>';
  17. iframe.src += "</FORM>" + embed + "</BODY></HTML>'";
  18. document.body.appendChild(iframe);
  19. f = document.getElementById('IFRAME');
  20. }
  22. function navigate(nav){
  24. if (nav == "f")
  25.  {
  26.     pageNo = pageNo + 1;
  27.     embed = "<EMBED src=/Catalog/Page" + pageNo + ".pdf scrollbar=1&amp;messages=0&amp;statusbar=0&amp;navpanes=0 width=600 height=650></EMBED>"
  28.  }
  29.  else if (nav == "b")
  30.  {
  31.     pageNo = pageNo - 1;
  32.     embed = "<EMBED src=/Catalog/Page" + pageNo + ".pdf scrollbar=1&amp;messages=0&amp;statusbar=0&amp;navpanes=0 width=600 height=650></EMBED>"
  33.  }
  34.  else if (nav == "i")
  35.  {
  36.      pageNo = 2;
  37.      embed = "<EMBED src=/Catalog/Page" + pageNo + ".pdf scrollbar=1&amp;messages=0&amp;statusbar=0&amp;navpanes=0 width=600 height=650></EMBED>"
  38.  }
  40. this.document.frames['IFRAME'].location.reload(true);
  42. }
Jul 20 '07 #1
3 5377
28 New Member
I've been working on this problem on and off for a while now. I need to dynamically embed a pdf into an iframe. It works fine but the pdf is not caching. I assume that this is because the iframe is dynamic so that each time a new pdf is opened, a new iframe is created? Is there a way around this? I moved this from asp to html so that it supposedly WOULD cache the pdf. Could it be because I call the create iframe function from the onLoad event (onLoad="makeIf rame()")? Here is the function I am using:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML><HEAD><TITLE>2007 Catalog</TITLE>
  3. <META http-equiv=Content-Type
  4. content="text/html; charset=windows-1252">
  5. <SCRIPT type="text/javascript">
  7. var pageNo;
  8. var nav;
  9. pageNo = 1;
  11. iframe = document.createElement("IFRAME");
  13. function makeIframe(nav) {
  15. if (nav == "f")
  16.  {
  17.     if (pageNo < 102)
  18.     {
  19.     pageNo = pageNo + 1;
  20.     }
  21.  }
  22.  else if (nav == "b")
  23.  {
  24.     if (pageNo != 1)
  25.     {
  26.     pageNo = pageNo - 1;
  27.     }
  28.  }
  29.  else if (nav == "i")
  30.  {
  31.      pageNo = 2;
  32.  }
  34. iframe.src = "javascript:'<HTML><HEAD>";
  35. iframe.src += "<TITLE>Dynamic IFrame</TITLE>";
  36. iframe.src += '</HEAD><BODY>';
  37. iframe.src += '<FORM method=get action=dummy.php>';
  38. iframe.src += "</FORM><EMBED src=/Catalog/Page_" + pageNo + ".pdf toolbar=0;scrollbar=1&amp;pagemode=none&amp;zoom=50&amp;messages=0&amp;statusbar=0&amp;navpanes=0 width=600 height=650></EMBED></BODY></HTML>'";
  39. document.body.appendChild(iframe);
  40. }
  41. </SCRIPT>
  42. <link href="../css/style.css" rel="stylesheet" type="text/css">
  43. <link rel="stylesheet" href="stylesheets/main.css" type="text/css">
  44. </HEAD><BODY style="margin:0%" onLoad="makeIframe()">
  45. <table>
  46. <tr>
  47. <td width = "50%"><font color="#0000A0">
  48. <b>2007 Catalog</b></font>
  49. </td>
  50. <td width = "13%"></td>
  51. <td width = "50%" align = "right">
  52. <input type = "button" name = "bPrevious" value = "Previous" onClick="makeIframe('b')">
  53. <input type = "button" name = "bNext" value = "Next" onClick="makeIframe('f')">
  54. <input type = "button" name = "bIndex" value = "Index" onClick = "makeIframe('i')">
  55. <input type = "button" name = "bClose" value = "Close" onClick = "this.close">
  56. </td>
  57. </tr>
  58. </table>
  59. </BODY>
  60. </HTML>
Jul 30 '07 #2
5,821 Recognized Expert Expert
Heya, polymorphic.

I can't be positive, but perhaps it has something to do with the fact that you are using embed tags.

What would happen if you just set the src of the iframe to the URI of the PDF?
Jul 30 '07 #3
28 New Member
Heya, polymorphic.

I can't be positive, but perhaps it has something to do with the fact that you are using embed tags.

What would happen if you just set the src of the iframe to the URI of the PDF?
Um, you could be right. The pdfs cache when I open the html independently of the rest of the site. However, if I link to the html page then no caching. What is the difference?

Here is the changed script:
Expand|Select|Wrap|Line Numbers
  1. <SCRIPT type="text/javascript">
  3. var pageNo;
  4. var nav;
  5. pageNo = 1;
  7. function makeIframe(nav) {
  9. if (nav == "f")
  10.  {
  11.     if (pageNo < 102)
  12.     {
  13.     pageNo = pageNo + 1;
  14.     }
  15.  }
  16.  else if (nav == "b")
  17.  {
  18.     if (pageNo != 1)
  19.     {
  20.     pageNo = pageNo - 1;
  21.     }
  22.  }
  23.  else if (nav == "i")
  24.  {
  25.      pageNo = 2;
  26.  }
  27. var iframe = document.createElement("IFRAME");
  28. iframe.setAttribute("src", "/Catalog/Page_" + pageNo + ".pdf");
  29. iframe.setAttribute("id", "contentFrom");
  30. document.body.appendChild(iframe);
  31. }
  32. </SCRIPT>
The href link is in an includes file (which is called from an asp file) as follows:

Expand|Select|Wrap|Line Numbers
  1. <!-- #include virtual="/includes/leftMenu.inc" -->
Expand|Select|Wrap|Line Numbers
  1. <tr>
  2.  <td><a href="catalog.html" target = "_blank" onMouseOut="MM_swapImgRestore();" onMouseOver="MM_swapImage('default_r3_c2','','images/default_r3_c2_f2.gif',1);"><img name="default_r3_c2" src="images/default_r3_c2.gif" width="160" height="40" border="0" alt=""></a></td>
  3. </tr>
I do not understand why it makes a difference.
Jul 31 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Templar | last post by:
Hi i'm bothering with such problem... I must dynamic create an Iframe, and then put som raw HTML into it. But I can't. When I create iframe, I can't access its properties. Here's the coe snipplet: //************************************* //*************************************
by: Dave Williamson | last post by:
When a ASPX page is created with dynamic controls based on what the user is doing the programmer must recreate the dynamic controls again on PostBack in the Page_Load so that it's events are wired and are called like a static control. Here is the problem that I need to solve. The processing overhead that occurs to determine what dynamic...
by: shlomi.schwartz | last post by:
using this example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test Page</title> </head>
by: spolsky | last post by:
hi, i have the following pages. when form submitted with the field1 value is "ok" then the iframe must be loaded with the text "Page loaded...". This works fine with IE 6 and FireFox(1.5) but Opera (9.01) does not refresh the iframe and loads the page for iframe from the cache, so refreshing the page gets the iframe refreshed with the new...
by: hyejin | last post by:
I have a problem with dynamic iframe and document.close() on Firefox. Below two files create a dynamic iframe by JavaScript. These two samples do not have any problems on IE. But, on Firefox, the icon on the top corner keeps running with "loading" message on the bottom status bar even though the browser completed everything in the iFrame. ...
by: pbd22 | last post by:
hi. i have a hidden iframe for uploading files. when i check the httpfilecollection on the server, it is always zero - the files never make it to the server. i know all the javascript is working correctly on the client b/c i have followed the local variables using venkman. so, something is happening on the server.
by: redbaks | last post by:
Hi! I am trying to implement adding widgets to our template editor (for blogs). I am worried that i might open a window for XSS attacks so i decided to enveloped all widgets inside an iframe. whenever a user wants to insert an external widget to his blog, a script takes over and it will create a dynamic iframe and then the widget script...
by: cdmsenthil | last post by:
I have an Infragistics UltrawebGrid . Each Row in the grid is attached to a context menu using Infragistics CSOM Upon click on the menu, I am creating an Iframe dynamically which points to another page in the same domain which also contains infragistics datagid populated with default data retrieved from Data Base. After creating the frame I...
by: chaitanyadotcom | last post by:
As per my application i need to create tabs using iFrame dynamically. There are totally 4 buttons in my application where for each button i provide a link. Where in it will dynamically create a tab inside the iFrame. For example.. first button contains google.com second button contains yahoo.com 3rd button contains hotmail.com if i...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.