Mac Google Chrome iframe Access Parent Window - macos

I am trying to access the parent window of an iframe and set the iframe's height.
The following code works on Windows IE7/IE8/Chrome/FireFox 3.6 and on Mac FireFox/Safari.
But on Mac Chrome it doesn't appear to be accessing the parent window.
On the parent page I have an iframe:
<iframe src="iframe_saleinfo.html" id="saleInformationIframe" frameborder="0"></iframe>
In the iframe.html:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', window.top.document);
theFrame.height($(document.body).height() + 30);
});
I have also tried:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', top.document);
theFrame.height($(document.body).height() + 30);
});
And I've tried:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', parent.document.body);
theFrame.height($(document.body).height() + 30);
});
And I tried:
$(document).ready(function() {
var theFrame = $('#saleInformationIframe', window.parent.document);
theFrame.height($(document.body).height() + 30);
});
Thanks in advance,
Jayde.

It looks like a local issue with Chrome Mac. I don't have a web server installed on the test mac but when I uploaded the files to a server and viewed it from there, everything appears to work.
Thanks,
Jayde.

Related

YouTube iFrame embed pausing after few seconds

I have a Mac OS X application and am using a WebView (webkit) to embed a YouTube iframe.
For some reason it keeps pausing on certain videos after a few seconds. It will just get stuck loading.
Flash NPAPI Plug-in version 18.0.0.160 is installed.
Xcode is also throwing an Error: Ignoring controlTimebase set by client because AVSampleBufferDisplayLayer was added to a synchronizer
Here is my code for the iFrame embed, the same one as YouTube provides.
<div id="ytplayer"></div>
<script>
document.body.setAttribute("style", "margin-left:0px;margin-top:0px;background-color:#000000");
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubePlayerAPIReady() {
player = new YT.Player('ytplayer', {
height: '200',
width: '300',
videoId: '%#',
playerVars: {
'controls': 0,
'html5': 1,
'autoplay': 1
}
});
}
</script>
It was working fine until a couple days ago. I believe YouTube might have updated something, which could just mean the error is on their end.

scroll function not working in google chrome

1)If i scroll the browser, if scrollTop() is greater than 50px then nav bar will come down.
2)It is working in Mozilla, but it is not working in Google Chrome.
3)In this i have inserted two libraries a)jquery-2.1.3.min.js b)bootstrap.min.js
4)below is the script what i wrote.
$(document).ready(function(){
$(document).scroll(function(){
var scroll_top=$("html").scrollTop();
if(scroll_top >= 50){
$("nav.navbar-default").addClass(" navbar-scroll");
}else{
$("nav.navbar-default").removeClass(" navbar-scroll");}
});
});
5)Here's the fiddle http://jsfiddle.net/vamsivelaga/waL67pkb/
Use "body" or document instead of html.
var scroll_top=$("body").scrollTop();
or document
var scroll_top=$(document).scrollTop();
Fiddle: http://jsfiddle.net/waL67pkb/1/

Load an add-on HTML page on Firefox startup

I have made a plugin using the addon SDK. The plugin adds a button to the nav-bar, and when it is clicked it opens a new tab with some data from an internal indexeddb using code similar to this:
// main.js
tabs.open({
url: self.data.url('index.html'),
onReady: runScript
});
function runScript(tab) {
var worker = tab.attach({
contentScriptFile: [
self.data.url("script.js")]
});
}
Everything works fine, except for the scenario where the user quits Firefox and opens it again, that tab will be restored, but it will contain nothing because it hasn't been triggered by the addon button click. This is because the scripts on the page are loaded through the runScript function in main.js, which is not executed when the HTML file is loaded on a restart.
How can I get this tab to have the same behavior on page startup than on button clicking?
I think you'll have to reload the tab:
exports.main = function(options) {
if(options.reason==='startup') for (var i=tabs.length-1; i>=0; i--) {
var tab = tabs[i];
if (tab.url!==self.data.url('index.html')) continue;
tab.once('ready', runScript.bind(null, tab));
tab.reload();
/* If it can't reload the tab,
use tab.url = self.data.url('index.html'); */
}
// ...
}
This a bug I had reported it awhile ago on bugzilla here
I added your topic as an example.
So what you have to do for now, is onReady, you have to turn you body into html datauri and set the location of the tab to this contents.
For example on ready:
var htmlDataUri = 'data:text/html,' + encodeURIComponent(document.documentElement.innerHTML);
//end make htmldatauri
document.location = htmlDataUri;

Firefox Addon builder: how to keep a panel shown

I have done a firefox addon using the Addon Builder. This addon display a panel containing a web page.
The problem I have is that I would like to keep this panel displayed and probably had a close button to hide it. Actually the panel disappear when we click out of the panel.
This is the code I use to make my panel:
var HauteurPopup = 400;
var LargeurPopup = 650;
function getPanel(contentURL){
var popupPanel = require("panel").Panel({
width:LargeurPopup,
height:HauteurPopup,
contentURL: contentURL
});
return popupPanel;
}
var btn = require("toolbarbutton").ToolbarButton({
id: 'propelink-button',
label: 'Propulesez ce lien!',
image: 'https://www.users.prplk.com/img/mini-logo-propel-bar.jpg',
onCommand: function() {
if (typeof(tabs.activeTab._worker) == 'undefined') {
let worker = tabs.activeTab.attach({
contentScript: btnContentScript
});
tabs.activeTab._worker = worker;
}
tabs.activeTab._worker.port.emit("btnContentScript");
var panelPopup = myPanel.getPanel("http://example.com");
panelPopup.show();
}
});
Someone know how to keep this panel displayed and close it adding a button?
Thanks in advance
In xul based extensions there is an option in the creation of the panel to accomplish that (panel.noautohide). In firefox-addon-sdk it seems that it doesn't exist. See 595040 – Add a "isPersistent" attribute for panels
Although it is mentioned that you can do a workaround by editing panel.js, but i never tried to do that, but you may want to give it a try.

changing Firefox addon sdk toolbarbutton icons at runtimes

I'm using the toolbarbutton library, because the normal widgets would not store their positions if I restart Firefox.
Unfortunately I want to change the icon on runtime. With the widgets I did:
widget.contentURL = "http://127.0.0.1:8082/static/icons/eth_16.png";
With the toolbarbuttons I tried:
Toolbarbutton.image = "http://127.0.0.1:8082/static/icons/eth_16.png";
without any effect. The image seems to be only used when construction the toolbarbutton.
Also tried to destroy and recreate the button with a different icon, but that causes annoying flickering.
Any idea would be appreciated.
I did a quick test and this should work as expected so I'm not sure what issue you're running into here. Here's some example code that works just fine:
var toolbarbutton = require("toolbarbutton");
var timer = require("timer");
var TEST_ICON_M_URL = "http://www.mozilla.org/media/img/favicon.png";
var TEST_ICON_G_URL = "http://www.google.com//images/google_favicon_128.png";
console.log("TEST_ICON_URL", TEST_ICON_M_URL);
var options = {
id: "test-tbb",
label: "TEST BUTTON",
toolbarID: "nav-bar",
image: TEST_ICON_M_URL,
forceMove: true
};
var tbb = toolbarbutton.ToolbarButton(options);
tbb.moveTo(options);
timer.setTimeout(function () {
tbb.image = TEST_ICON_G_URL;
console.log("switched", TEST_ICON_G_URL);
}, 5 * 1000); // 5 seconds
Is there more code you could post? The problem must be somewhere else.

Resources