Thanks PhistucK, almost there I hope!
I got the shadowbox to show up now but the box stays black after
briefly stating "loading". The title of the box (testing...) is there
so it's working at least somehow, however I can't get anything to load
in it. Here's the background page as you instructed:
<script>
function createShadowbox(info, tab) {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.insertCSS(
tab.id, {file: "shadowbox/shadowbox.css"});
});
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.executeScript(
tab.id, {file: "shadowbox/shadowbox.js"});
});
chrome.tabs.executeScript(
tab.id, {code: 'Shadowbox.init();
Shadowbox.open({ title: "testing...", content: "http://
www.google.com", player: "iframe", width: 400, height: 400 });'});
chrome.tabs.getSelected(null, function(tab) {
});
}
chrome.contextMenus.create({title: "Open Google in iframe", contexts:
["all"], onclick: createShadowbox});
</script>
Again, this code works fine running from a normal html file. Here's my
manifest in case anything's wrong with it:
{
"name": "Shadowbox",
"version": "1.0",
"description": "Shadowbox",
"background_page": "background.html",
"options_page": "options.html",
"permissions": [
"contextMenus",
"tabs",
"http://*/*"
],
"icons": {
"16": "icon16.png",
"48": "icon48.png"
},
"minimum_chrome_version": "6"
}
As both webpages (in iframe) and images show up fine through a normal
html file it might have something to do with permissions? Or maybe
relative paths could have something to do with it? Just guessing here,
any help is again immensely appreciated!
Almost there! :)
Oscar
> scripts<
http://code.google.com/chrome/extensions/content_scripts.html>or
> executeScript<
http://code.google.com/chrome/extensions/tabs.html#method-executeScript>in
> order to inject script into a web page.
> The background page can call
> executeScript<
http://code.google.com/chrome/extensions/tabs.html#method-executeScript>on
> the
> getSelected<
http://code.google.com/chrome/extensions/tabs.html#method-getSelected>tab
> or on the tab on which the context menu option was selected.
> Calling executeScript twice - once for loading the "shadowbox.js" file and
> the other for execute that code -
> function createShadowbox() {
> Shadowbox.init();
> Shadowbox.open({
> content: "
http://www.google.com",
> player: "iframe",
> width: 400,
> height: 400
> });
> window.open('
http://www.bing.com');// OPTIONAL, FOR TESTING
>
> }
>
> And you should be good to go.
> If you prefer not to use the contextMenu feature, you can inject a content
> script that will add this button and do the rest.
>
> ☆*PhistucK*
> > To post to this group, send email to
chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> >
chromium-extensions+unsubscr...@chromium.org<
chromium-extensions%2Bunsubscr...@chromium.org>
> > .