Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    javascript events in firefox versus ie

    Hello,
    I am making a java servlet that generates a menu. It's to difficult to determine the exact browser in java. However, I made one in javascript. Depending on the browser(IE supports by default the onclick and onchange event), I have to make my admin menu for IE & other browsers that don't support it by default. It are a few dozen buttons that should listen to click events and a few dozen text fields(input type=text) that should listen to change events. Now here is my problem: they don't listen to the events, not change events or click events.
    I have three browsers that I have tested it on: Mozilla 5.0, FireFox/1.0 & IE6. The only one that executes it normally is IE6. Here is my script:
    function doAction()
    {
    var oSource=window.event.srcElement;
    var iden=oSource.name;
    window.open("/servlet/menus.DBMenuUpdate?dbname=haegens_vva&operation="+iden,"_self");
    }
    function capture()
    {
    document.captureEvents(Event.CLICK);
    document.onclick=doAction;
    document.onchange=saveChange;
    }
    function saveChange()
    {
    var oSource=window.event.srcElement;
    var naam=oSource.name;
    var waarde=oSource.value;
    var newobj=document.createElement("input");
    var counter=commands.childNodes.length;
    newobj.type="hidden";
    newobj.name="command"+counter;
    newobj.value="Change "+naam+" To "+waarde;
    var obj=commands.insertAdjacentElement("beforeEnd",newobj);
    }
    the function capture() is called here:
    <body onload="capture();">
    the function doAction() should be called here:
    <input type="button" id="cmdVerwijderen12" name="cmdVerwijderen12" onclick="doAction()">
    the function saveChange() is called here:
    <input name="txtLink110" onChange="saveChange()" type="text" value="Prov_Antwerpen.htm" size="50" maxlength="50">.
    Can someone please help me out?

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    captureEvents is IE-only.

  • #3
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually, the place where I got it from, claims it's for netscape. That's why I used that code. Of course, my source could be mistaken.

  • #4
    New to the CF scene
    Join Date
    Jan 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found out why it didn't work:
    1.) window.event has no methods in firefox.
    2.) I had to define "commands" first before I could use it, even if it has an id.
    3.) insertAdjacentElement is not a method supported by firefox.
    here is my altered code:
    function eventTrigger (e)
    {
    if (! e)
    e = event;
    return e.target || e.srcElement;
    }
    function saveChange(e)
    {
    var oSource=eventTrigger(e);
    var naam=oSource.name;
    var waarde=oSource.value;
    var newobj=document.createElement("input");
    var commands=document.getElementById("commands");
    var counter=commands.childNodes.length;
    newobj.type="hidden";
    newobj.name="command"+counter;
    newobj.value="Change "+naam+" To "+waarde;
    var obj=commands.appendChild(newobj);
    return true;
    }
    function doAction(e)
    {
    var oSource=eventTrigger(e);
    var iden=oSource.name;
    if(oSource.type=="button")
    window.open("/servlet/menus.DBMenuUpdate?dbname=haegens_vva&operation="+iden,"_self");
    return true;
    }
    here is the html code:
    <input type="text" onChange="return saveChange(event)" name="txtNaam00" value="Actief/LID worden"></td></tr>
    <Input Type=Button Name=cmdWijzigen13 value="Wijzigen" onClick="return doAction(event)">
    Last edited by haegens_nico; 01-25-2005 at 02:55 PM. Reason: forgot something

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by hemebond
    captureEvents is IE-only.
    It's NS4 only.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •