I have the following scenario,
I'm loading an iframe in a page where I have full control over,
The inside of the iframe is a webpage that embeds a flash file. I have no control over the inside of the iframe (that includes the actual flash and the webpage that embeds the flash).
I want to know if there was a GET request to download a certain image. The GET request is originated by the flash file.
Note: I can see the images that the flash loads if I click CTRL+SHIFT+I on Chrome under resources if that helps you understand how the flash movie gets the images.
Is that possible?
Directly no; you can't to this regardless of whether you own the iframe and the SWF or not. So the answer is a no, not unless you own the images being requested and you can implement some sort of server-side static resources tracker.
Or you can always decompile the swf file (which is highly discouraged).
Related
I have a code like:
<iframe src="http://www.upnp.org/download/UPNP_understandingUPNP.doc"></iframe>
When this code is rendered, browser file download prompt is shown to user. I'd want to prohibit iframe from showing this download popup.
Is it possible?
I'd want it as iframe's url is controlled by users, not site owner.
No.
The server hosting the URL can decide if it wants to mark it as an attachment (suggesting that the browser to save it) or inline (suggesting that the browser should open it; using a plugin if one is available).
The browser decides how to handle it.
The page linking to it (even if it does so via an iframe) has no control over any of the above.
To avoid the download popup, you could use ajax instead of an iframe to load the url.
I'm building a social bookmarking application for use within large companies.
It has a simple JavaScript bookmarklet which currently works fine - the bookmarklet allowes users to save a bookmark from popular browsers. It works for public web links quite well - and is fairly browser-agnostic. The closest example of such a bookmarklet is this:
http://delicious.com/help/bookmarklets
When I am viewing a PDF in my browser (let's say Chrome/Mac):
http://website.com/file.pdf
This does not work of course - since there is no way to inject HTML markup on top of a PDF being viewed in-browser.
What is the best approach to making links to non-http resources work within a bookmarklet? Do I have to create then inject some kind of invisible iframe and then grab a parent frame and it's URL to be able to save it?
I don't know about all browsers, but in Firefox you can inject Javascript and iFrames over PDF files and images. This is because images and PDF files are actually displayed inside special dummy HTML pages generated by Firefox. I think Chrome may be the same.
You can see this for yourself by opening a PDF or image and then opening the Web Console (must use menu, can not use CTRL+SHIFT+K in this case) to get the JS console and then type document.documentElement.outerHTML to see the actual dummy HTML where the PDF or image is embedded.
To detect situations where I can not add an iFrame or other HTML to a page, I might test if document.documentElement is defined, or possibly some other DOM element.
For any browser or file-type combination where this will not work, or if I just wanted to keep things more simple, I'd open a page on my server in a new tab or window and pass the page title and location to that page like http://mysocialsite.tld/add-bookmark?title=file.pdf&location=http://anothersite.tld/file.pdf. That page on my server would let the user complete the bookmarking process.
I want to take a screenshot from my website of another website or preferable 1 part of it (an object tag).
I want it to work this way: I click on a button that will send a request to screenshot the page at this moment. Several ideas are insert the page inside a flash object and screenshot it. Or opening a browser on the server and when I click the button send a request using AJAX to tell the server to screenshot with this browser.
How should I do this because I kind of failing right now with the flash Idea. The page I am trying to screenshot is a live camera that uses a .wvx object. But I can't even do that with a .swf object.
Thanks!
You can try phantomjs. They have several examples of renderding page output. It supports plugins like flash too.
render() always renders the entire page. To just render one <object> tag, I guess you can do one of:
create a page that only contains that <object> tag.
use javascript to remove everything else.
crop the final screenshot based on <object> page coordinates.
To use phantomjs from php, try php-PhantomjsRunner.
Edit 1: In case you only want to render a flash file that does not actually rely on the web page it is in, you can try Gnash according to the blog post "Server-side PNG rendering of SWF images using Gnash" by Valentine Bichkovsky.
phantomjs screen-scraping
I've developed some javascript code that renders an iframe on the page. Inside the frame, it loads various API's for social networking, such as facebook, twitter, linked in, etc. It's basically a tool for the website to allow users to sign in with their social network. I've also created a simple jQuery plugin that loads this iframe into a modal popup.
Here's the problem:
The main iframe is loaded on the site, but the developer also wants to use the jquery plugin on the same page. It works fine, but ALL of the javascript is being loaded a 2nd time. So basically it is a huge waste of resources, as every social networking api is being loaded twice. I was wondering if there was a way to track that the api's have already been loaded, and to stop loading them again. The 2 iframes are exactly identical.
I tried adding some properties to window.top, but this doesn't work because of cross domain limitations. The two iframes are of the same domain, but the main site is a different domain.
I was also wondering if an iframe can detect if the main window has loaded jquery, as that is being loaded again even when it's not necessary.
Any advice and suggestion would be appreciated,
Thanks!
You should not use an iframe for this. It sounds like you are creating a 'login pop-up' for users to login, say if they clicked 'comment' and were not already logged in. Just use a div, and float it absolutely above the rest of page.
When embedding a flash object, is there a way to determine when it's fully loaded?
That's my basic question, but for anyone interested in the details behind it:
I am using the (DOMWindow) jQuery plugin. For those not familiar, it's a basic overlay the appears centered on the page, above all other content which is dimmed.
Inside of the DOMWindow, I am embedded a YouTube video. The markup used to embed the video is AJAX injected.
The DOMWindow has a built in loading graphic, but the problem I am having is that the AJAX GET request is completed almost instantly, and for 3-5 seconds, I'm stuck looking at a white rectangle while waiting for the YouTube video to load.
If I could figure out how to determine when it's finished loading, I could code a more graceful loading scheme (using a animated spinner) inside of the DOMWindow.
You should take a look at this page Youtube Player Javascript API. Subscribing to the onStateChange Event and looking for it to return 5 appears to be what you want to do.
I'll leave my original answer, in case it might still be handy. It is below.
You may want to look at this blog entry. He is passing Flash events to javascript to monitor a video. He specifically mentions waiting for the movie to dl and attach to the player. I'm not sure these techniques work with the youtube player.
It you're looking for a more general Flash reference, Flash makes available OnProgress, OnReadyStateChange and PercentLoaded as Javascript properties of the OBJECT or EMBED element. http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html
The ultimate way to do this is to get some kind of confirmation from the Flash that it is ready to display (as with, in this case, a YouTube API).
Short of that, there's no objective point when a Flash movie is finished loading. Once the first frame is loaded it can display initial content while later content loads, and even if the root SWF file is loaded, it may need to load more external content before it can display anything. (YouTube probably falls into this latter category, as will any service where the content is loaded by the container SWF.)