chengyin / WhatFont-Bookmarklet

The core of WhatFont Tool
http://chengyinliu.com/whatfont.html
University of Illinois/NCSA Open Source License
489 stars 75 forks source link

iframe fail #5

Open albell opened 12 years ago

albell commented 12 years ago

Thanks for this. Very clever and useful. This is something the various Dev Tools Inspectors should really implement natively. Congrats on beating them to it!

One issue: In chrome 21, the plugin doesn't work on text inside an iframe. No bubble pops up at all. Try inspecting the results pane here:

http://jsfiddle.net/Wsmfv/

Any fix greatly appreciated.

chengyin commented 12 years ago

Sorry for the late reply.

I will have to look into it. I intentionally avoid iframe because I can't simply use the same scope between the main window and the iframe ones. It will show another WF instance in the iframe, which is not good.

glajchs commented 11 years ago

I also ran into this problem when trying to debug some font usages in my iframe. My iframe is inserted via the chrome extension I'm building (it's basically a toolbar at the top of the page to help users instrument their website with our product). You could use the same method I'm using to talk to the iframe, which is you send messages to your background page for your extension via chrome's extension messaging API, and then the background page sends a message to all frames in the current page like so: chrome.tabs.sendMessage( tabId, { allFrames: true, dataToSend: {} ); Make sure to set tabId to the sender.tab.id from the request that you sent to the background page.

In your manifest, specify that the content scripts should run in all frames like so: "content_scripts" : [ { // other stuff here... "all_frames" : true } Then in your content scripts you can listen for chrome extension events via: chrome.extension.onMessage.addListener( function(request, sender, sendResponse) { } ); In this way you can send data to/from your iframes, do calculations within the actual iframe's scope to determine fonts via the content scripts, and send the result of your calculations back to the top-level page.

You will of course have to conditionalize the logic within your content scripts to do different stuff based upon whether they are running in the toplevel or in an iframe, so there is a bit of work involved there.

But it may be worth the feature. I know I'd love to see it :-)