开发者

Detecting window load with XUL and running a Javascript function?

开发者 https://www.devze.com 2023-01-06 04:17 出处:网络
I am developing my first addon for Firefox, and I\'m using the Extention Developer addon to help me. It has a real time XUL editor which I am using to design my form.

I am developing my first addon for Firefox, and I'm using the Extention Developer addon to help me. It has a real time XUL editor which I am using to design my form.

At the moment this is what I have:

<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="yourwindow" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml">
<vbox>
    <label control="masterPassLabel" value="Master password:" />
    <textbox id="masterPass" value="" type="password" />
    <label control="siteNameLabel" value="Site name (defaults to current URL):" />
    <textbox id开发者_StackOverflow="siteName" value="" />
</vbox>
<button label="Generate" oncommand="generatePass()" />
<script type="text/javascript">
<![CDATA[
// put some js code here

siteName.value = window.location;

function generatePass() {
    //password generating code
}
]]>
</script>
</window>

I want to automatically populate the siteName textbox with the current URL when that form is loaded. And perhaps add some input validation so if there's no page loaded at that time it will show an error?

I'm new to XUL and developing Firefox addons. I have read through a lot of their documents already but I am still learning.

Thanks. :)


Add a function call to the "onload" event attribute of your window.


The following page got me sorted with a similar requirement:

Detecting window load with XUL and running a Javascript function

-FM

0

精彩评论

暂无评论...
验证码 换一张
取 消