How to removes a link from iframe - javascript

I hvae iframe code like this
<iframe id="iframe" align="left" style="background-color:#000000" src="//third party url" frameborder="0" height="85" width="300" scrolling="no">
Now it generates a link inside body.& i want to remove a link from that.
Any suggestions??

If the iframe src points to another server than yours, you cannot alter its HTML (the cross-domain restriction).
You can however hide the link by Javascript or CSS if you can control somehow the third party server (a method named JSONP).

You can't do that from the Javascript as it is from external site. Alternately you can do it from server side (either PHP/ASP.NET or others) using CURL or respective syntax to read the content and change before serving. It should work without any issues.

Related

Is it possible to change HTTP-header of a pdf document, you want to embed in a <embed> or <iframe>?

Refering to my other question: Why does pdf document download instead of showing in a embed/iframe?
When i embed a pdf document like the below examples, it downloads the documents instead of showing it embedded in the website.
<embed id="showPdfDocument" src="http://example.com:8080/client/attachment/filename.pdf" type="application/pdf" width="400" height="400">
or
<iframe id="showPdfDocument" src="http://example.com:8080/client/attachment/filename.pdf" style="width:400px;height:400px;"></iframe>
My assumptions:
I guess i have to change the HTTP-Header of the pdf document?
I also guess that the problem is with the field "Content-Disposition: attachment", as shown in the screenshot below
My question:
How can i change the HTTP-Header of the pdf document, using html/javascript only? (Greasemonkey for example)
Screenshot of the HTTP-Header of the pdf document:
("Chrome Dev-Tools(F12)" -> Network Tab, select the pdf document and check the response headers)
The content-disposition header triggers the save dialog. If you want to avoid it without server-side changes, try loading it via XHR and encode it as "data:" link.

jQuery AJAX URL getting folder prepended from iframe

I am trying to make a jQuery AJAX call from an iframe. I can't put my code here, but I will try to create a similar example.
My actual page is served from localhost:3000/dev-file-import. The page contains the code to render an iframe like the below
<iframe id="fileimport"
src="../../fileimport/index.html?${encodeURI(dataToIframe()}"
title="fileimport"
width="100%"
height={600}
frameBorder="0">
The index.html contains an AJAX call which should be like https://localhost:3000/mock/../../... but when the AJAX call is happening from the iframe it's prepending the iframe path as well, ie. https://localhost:3000/**fileimport**/mock/...
How can I stop the fileimport getting prepended when the AJAX call happens?
FYI: My parent application is in React, and the iframe code is in jQuery.
Please find the folder structure below
My folder structure
iframe code from public

Phantomjs: Modifying html dom before opening it as webpage

I need to process html files that have corrupted script files that are added to it via tag.
Im planning to remove all script tag present in the webpage via phantomjs.
But on opening the webpage via webpage.open(), phantomjs parse error is thrown since it cannot parse the JS content within the script tag.
Here is an example:
<html>
<head>
<script>
corrupted JS
if(dadadd
;
</script>
<body>
some content
</body>
</html>
Can someone help me on suggesting the right way to clean this webpage using phantomjs ?
It's not (easily) possible. You could download (not through opening the page, but rather making an Ajax request in page.evaluate()) the static html, then change according to your needs, then assign it to page.content.
This still might not work, because as soon as you assign it to page.content, you're saying that PhantomJS should interpret this source as a page from an unknown domain (about:blank). Since the page source contains all kinds of links/scripts/stylesheets without a domain name, you'll have to change those too in order for the page to successfully load all kinds of resources.
It might be easier to just have a proxy between PhantomJS and the internet with a custom rule to adjust the page source to your needs.

Opening a local pdf file in iframe with javascript

I am using the below code to open a pdf file but its not working-
<iframe src="file:///C:\Users\Downloads\0895custbill08132015.pdf" style="height: 638px;" frameborder="0"></iframe>
For a google doc the below code is working fine, I am not sure what is required to open a locally saved doc.
<iframe src="http://docs.google.com/gview?url=http://webshire-aioopsss.com/pdfs/sample_contract.pdf&embedded=true" style="height:638px;" frameborder="0"></iframe>
Most browsers won't let you open a locally stored file from a website for security reasons. Typically I will host the file on an IIS server and then retrieve it from there (which is what you're doing when you're retrieving it from googledoc).
You are using backslashes in your src. Please change them to slashes
<iframe src="file:///C:/Users/Downloads/0895custbill08132015.pdf" style="height: 638px;" frameborder="0"></iframe>
You can use
var pdf = $('\<\object type="application/pdf">');
pdf.attr('data', "you pdf scr");
append it in your iframe..

Load and show a page from another domain without showing the orginal URL, using javascript

I am trying to load a page from a domain (say abc.com) to my website (say xyz.com). I would like to show a page from abc.com within xyz.com without showing the original URL. This means the site visitor will not be able to find out the original source URL (abc.com).
Make a page in your website and put an iframe in it and set the url of that iframe as url of the page of the other website, in this way the page will be loaded from other site and url will be of your site.
<iframe src="http://www.abc.com/thepage" style="border-width:0;width:100%; height:800px;"></iframe>
<iframe src="http://www.xyz.com/thepage" width="300" height="300" frameBorder="0"></iframe>
Then you need to configure you server to act as reverse proxy to abc.com for the /thePage

Categories