How to refresh/reload embed of application/pdf? - javascript

I have an embed code using application/pdf to show a pdf document on the page.
I used javascript to change the src attribute of the embed, which a link is clicked. then confimed using alerts to see that the src did change.
but the same pdf is still showing on the page.
How do I refresh/reload the embed tag (not the whole page)? I think this will fix it.

How do you embed the PDF? If you are using an iframe, you can use the reload method.
<iframe id="myIframe" src="your.pdf" height="200" width="200"></iframe>
<script language="javascript" type="text/javascript">
getElementById('myIframe').contentDocument.location.reload()
</script>
You can also append a random string (like the current timestamp) as a GET parameter to the PDF URL to make sure the browser doesn't use its cache.

Related

Removing or hiding elements from a webpage within a chrome web extension (manifest 3)

This is my first post ever. Please be considerate.
I have an iframe :
<div>
<iframe id="myIFrame" src="https://app.repree.com" width="500" height="500" title="description"></iframe>
</div>
<script src="popup.js"></script>
</body>
I would like to go through the login (working as of now) and then remove or hide some of the HTML tags (not working as of now) so that only certain key features of the website appear.
Say.. only Activities and forms tab. (View picture for reference) Page after login
Each time I try to access the html of the iFrame, a null exception is shown to me. Thus, making me unable to affect the display of the page.
If anyone has any ideas, do please tell.
What I have tried so far:
Using JQuery
iFrame alternatives (webview, etc) : these would not display anything at all!
What I expected
JQuery would remove the elements successfully.

How to insert iframe in wordpress using dashboard

I want to insert iframe in my wordpress website.
however i am unable to do so.
here is my code:
<iframe id="eventListIframe" src="http://www.example.com/widgets/eventList_.php?id=781ea4dab64042de4fbdc6d9102ef0e7" frameborder="0" scrolling="no" style="width:100%;" ></iframe><script type="text/javascript" src="http://www.example.com/widgets/iframeResizer.min.js"></script><script type="text/javascript">iFrameResize({log:false,enablePublicMethods:true});</script>
when i check on my website , i get iFrameResize({log:false,enablePublicMethods:true}); text as output.
To embed one web page (the data visualization) inside a second web page (the organization's website), we use a simple HTML code known as iframe.
WordPress removes iframe html tags because of security reasons. Iframe shortcode is the replacement of the iframe html tag and accepts the same params as iframe html tag does. You may use iframe shortcode to embed content from YouTube, Vimeo, Google Maps or from any external page.
https://wordpress.org/plugins/iframe/
If you want to go through other way - Code
https://wordpress.stackexchange.com/questions/20202/embed-iframe-or-html-page-into-dashboard-widget

Change Chrome extension tab title

My Chrome extension create a tab using the API
chrome.tabs.create({
'url': other_extension_url
})
The url is the the url of another extension and looks like:
chrome-extension://ext_id_goes_here/url
I would like to change the the title of the newly created tab (document.title).
I tried to do it using content script but as far as I understand there is no way to use content script with url that looks like chrome-extension://
Is there an any other way to do that?
No, there is no way to do that, since security model will not allow you to access other extensions' pages.
The title is set by the document itself, and cannot be modified by tabs API.
Here is one way to do it.
<html>
<head>
<title>My title</title>
</head>
<body style="margin:0;padding:0;overflow:hidden;">
<iframe style="width:100%;height:100%;" src="chrome-extension://extension_id/page.html"></iframe>
</body>
</html>
Note I haven't tried it from within an extension html but it did work from a html file:// opening an extension page in the iframe.
Based on this, you can have a single "wrapper" page that receives the title and the iframe url as a url parameter and updates its DOM to change the title and iframe src.

How to disable pdf toolbar download button in iframe

I have a web service which will return pdf stream for a given document id and I will set the content type to application/pdf and write the out put to IFRAME upto this point I am done and OK!
My problem is :
My requirement is to disable the pdf download toolbar button in IFRAME, is there any way using JavaScript or j query to disable the PDF toolbar buttons,
i tried some thing like this:
<iframe src="view/1.pdf?page=hsn#toolbar=0" width="875" height="95%" id="iframe11">
<p>Your browser does not support iframes.</p>
</iframe>
I tried setting toolbar=0 for iframe tag but it dint work.
an anyone please tell me how to achieve this ?
I hope I am not very late to reply. But here's is something you can do to prevent the users. Use iFrame to display your PDF and make sure that you are displaying using Google. I used the following code :
<iframe src="http://docs.google.com/gview?url=http://www.tutorialspoint.com/php/php_tutorial.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
</iframe>
Here you can simply change the url=http://www.tutorialspoint.com/php/php_tutorial.pdf and replace it by your own URL where you kept your PDF.
Use embed tag instead iframe tag:
<embed src="http://localhost/yourpdf.pdf#toolbar=0" style="width:600px; height:500px;">

Javascript in Iframe within Div not working

I have a webpage that I would like to embed within another page. On the page that is to be embedded I have some window.onload javascript that will load a PDF document via the embed tag. If I use just the Iframe tag like this:
<iframe name="content" id="iframe" allowtransparency="true" src="Pages/menu.html" scrolling="no"></iframe>
The Javascript will run just fine. But I am trying to create a background and border for the iframe so I have wrapped the iframe in a div like so:
<div id="content" class="border">
<iframe name="content" id="iframe" allowtransparency="true" src="Pages/menu.html" scrolling="no"></iframe>
</div>
As soon as I do it this way the javascript will not run. Here is the screenshot of what I am trying to do. I do not believe that the styling that is present on the div ( curved borders, gradient, etc is possible on an iframe)
I am using PDFObject to generate the PDF on the page. The iframe is also loading the company's external website in the content section on demand and this is what they want so unfortunately i have to use iframes. This has to be done without using anything except javascript as well otherwise I would just use php.
I have to post the SCREENSHOT outside of this site on photobucket due to restritions sorry:
http://i721.photobucket.com/albums/ww217/the_t3rminat0r/Capture-2.png
It looks margin property in div style (or border class in your example) causes the problem.

Categories

Resources