changing the content of browser in XULRunner - browser

I have an Xulrunner app that loads fullscreen without any controls and loads a html page by default. The only thing it has is browser element and a popup menu visible on right click.
In the popup menu there is option to quit. Then there is a menu entry 'theme2'. I want the browser to load another html when theme2 is clicked.
This is my main.xul, thats loaded by default:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="main" title="Edusoft" hidechrome="true" sizemode="maximized" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript">
function do()
{
var browser1 = document.getElementById('browser');
browser1.loadURI("chrome://myapp/content/theme2/home.html");
}
</script>
<browser id="browser" type="content" src="chrome://myapp/content/theme1/index.html" flex="1" context="clipmenu"/>
<popupset>
<menupopup id="clipmenu">
<menuitem label="About Us"/>
<menuseparator/>
<menuitem label="Theme2" oncommand="do();"/>
<menuseparator/>
<menuitem label="Exit" oncommand="close();"/>
</menupopup>
</popupset>
</window>
I tried this, but when the page is loaded this way.. the popup menu is nomore in the new page.
window.location.assign()
There is something like loaduri(), but i have no idea on how to use it.

Ok I figured it out.
document.getElementById('browser').loadURI('chrome://myapp/content/flash/demo.htm')

Related

No openerTabId property for popup windows

I got two htmls as follows.
index1.html
<html>
<body>
<button
onclick="
window.open(
'https://www.google.com',
'sample')">
click
</button>
</body>
</html>
index2.html
<html>
<body>
<button
onclick="
window.open(
'https://www.google.com',
'sample',
'height=200,width=150')">
click
</button>
</body>
</html>
button click on index1 page opens Google page next to the current tab in the same window while index2 opens it as a popup window.
I'm listening to chrome.tabs.onCreated events in the background.
background.js
chrome.tabs.onCreated.addListener(tab => console.log(tab.openerTabId));
// results
//index1 >>> 42
//index2 >>> undefined
Here I believe openerTabId should exist for popup windows as well. chrome.tabs.get() results for the popup tab also doesn't contain openerTabId. However, window.opener object is not null in the popup window.
From https://developers.chrome.com/extensions/tabs#type-Tab
The ID of the tab that opened this tab, if any. This property is only present if the opener tab still exists.
In my case, the opener tab exists. Sounds like a bug?
Note that this is not the exact solution but I found out that chrome.webNavigation.onCreatedNavigationTarget event passes sourceTabId property which is the openerTabId. However, this requires webNavigation permission.

How can I get rid of the call to action button on my Weebly site?

I can't find any way to get rid of the call to action button on my landing page layout in Weebly. Is it possible to get rid of this button?
You need to perform two steps.
Remove the button from the desktop layout.
Open the layout file in HTML edit mode.
Remove the following line:
<div class="button-wrap">{action:button global="false"}</div>
Remove the button from the mobile layout.
Add the following script to the Header Code of the page:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
</script>
<script language='javascript'>
$(document).ready(function(){
$('.landing-container').remove();
});
</script>
You can see it in action on this site for gluten free products.

Page action to open new page

Can I use a page action to directly open a new page? I have a link in my popup.html, but it would be better to have the page open when they click the icon so that they would only need one click instead of two.
<!doctype html>
<html>
<head>
<title>Popup</title>
<link href="popup.css" rel="stylesheet" type="text/css">
</head>
<body>
click here
</body>
</html>
Yes, a way to achieve this would be as follows:
chrome.pageAction.onClicked.addListener(function(tab){
chrome.tabs.create({url: "http://www.domain.com/details.html", "active":true});
});
See Chrome Page Action | onClicked
Note that you will need to declare the tabs permission in your manifest file:
"permissions": ["tabs",...],
I don't think there is any elegant way to handle both the situations on page action click:
Open popup
Open a new page
If you always want to open a new tab with some URL whenever page action is clicked, just remove the popup. And use the code just like #Flo has mentioned.
chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.create({url: "http://www.example.com", "active":true});
});
PS: To remove the popup, there are two options:
Remove the popup from manifest.json
Pragmatically like chrome.pageAction.setPopup('')

Primefaces p:overlayPanel show on right click, prevent browser contextMenu?

<p:overlayPanel showEvent="contextmenu" ..>
I like to show the overlay on right click. The browser also shows its context menu.
Is there a way to prevent browser showing its context menu?
Thanks.
You can write a javaScript function to disable browser contextMenu. Something like this
<script type="text/javascript">
document.oncontextmenu=function(){return false};
</script>
For your information, This technique will fail if the user disables JavaScript.

Dojo layout rendering problem

Press F5 in this example: DojoToolkit.
First the content is shown, and after that the layout gets into it's final state. In my application I want the opposite, so that the layout gets rendered, and after that the content is displayed. I don't want that 'jumping' phenomenon when loading. Is it possible to fix this somehow?
No, I don't think that there is such an option. Anyway, you could use a container div (with all the dojo layout elements in it) with initial state visbility:hidden, and after the page is loaded and parsed change it's visibility to "visible".
<div id="container" style="visibility:hidden">
<!-- dijit widgets inside the "container"-->
</div>
<script type="text/javascript">
dojo.ready(function(){
dojo.style("container:, "visibility", "visible");
});
</script>

Resources