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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    invoking Javascript function throws "Object expected", why?

    Friends,

    My very simple function clickEvent1() (defined in the page head) that expands/shrinks a hidden tag <h6> with text, id="lignep" in the body

    Here is a code which throws error for line 104 in the page body with message "Object expected", but I can't figure out what is wrong in this line that calls for function clickEvent1():

    <h6 id="ligne"; onClick="clickEvent1()"; style="font-size: 12pt; line-height: 130%">

    Thanks much!

    AT

    Here the page with Javascript in the title:
    <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns="urn:schemas-microsoft-comffic... xmlns="http://www.w3.org/TR/REC-html40">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta name="GENERATOR" content="Microsoft FrontPage 6.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <style>

    h2
    {margin-bottom:.0001pt;
    text-align:center;
    page-break-after:avoid;
    border:medium none;
    padding:0in;
    font-size:16.0pt;
    font-family:"Times New Roman";
    margin-left:0in; margin-right:0in; margin-top:0in}
    table.MsoNormalTable
    {mso-style-parent:"";
    font-size:10.0pt;
    font-family:"Times New Roman"}

    </style>

    <script language="JavaScript">

    alert("On va tester Expand and Collapse Text au moyen de tag1 = P et id = para");

    function onMouseoverEvent()
    {
    alert("Alors commencons par testant si tag H3 est dans le texte");
    {
    var tag1, parentTag1;
    tag1 = window.event.srcElement.tagName;
    parentTag1 = window.event.srcElement.parentElement.ta...
    if (tag1 == "H3" && parentTag1 == "BODY")
    {
    if (document.all(window.event.srcElement.id + "p").style.display == "none")
    {
    document.all(window.event.srcElement.... + "p").style.display = "";
    }
    else
    {document.all(window.event.srcElement... + "p").style.display = "none";
    }
    }
    }


    function clickEvent1()
    {
    var tag1, parenTag1;
    tag1 = window.event.srcElement.tagName;
    tag2 = window.event.srcElement.parentElement.ta...

    if (tag1 == "H6" && tag2 == "DIV")
    {
    if (document.all(window.event.srcElement.id + "p").style.display == "none")
    {
    document.all(window.event.srcElement.id + "p").style.display = "";
    }
    else
    {
    document.all(window.event.srcElement.id + "p").style.display = "none";
    }
    }
    }


    function clickEvent2()
    {
    var tag1, tag2;
    tag1 = window.event.srcElement.tagName;

    tag2 = window.event.srcElement.id;

    if (tag1 == "P" && tag2 == "PARA")
    {
    alert("On a trouvé tag1 = P et id = para");
    if (document.all(window.event.srcElement.id + "p").style.display == "none")
    {
    document.all(window.event.srcElement.id + "p").style.display = "";
    }
    else
    {
    document.all(window.event.srcElement.id + "p").style.display = "none";
    }
    }
    }
    }

    </script>

    </head>

    <body bgcolor="#8DEEEE"; onDblclick="clickEvent2()"; onKeydown="alert('Ca marche?')">

    <h3 id="test" onMouseover="onMouseoverEvent()"> C'est un titre qui devrait s'ouvrir sur un texte si l'on le clique</h3>

    <h3 id="testp" style="display: none"> Voila le texte dont on parle en-haut: il doit s'ouvrir, dah-dah! </h3>

    <br><br><br>

    <!-- div ligne pour fonction clickEvent() commence ici -->
    <div style="background-color: #99CCFF">

    <h6 id="ligne"; onClick="clickEvent1()"; style="font-size: 12pt; line-height: 130%">

    Course description: Upon completion of the course the students are expected to understand and
    address the following skills and problem areas related to their personal
    leadership capacity in managerial and organizational settings:

    </h6>

    <h6 id="lignep"; style="display: none">

    Personality Types, Career Goals, Career Life Stages and Career Development tasks</span></p>

    <p>Time Management and Planning ideas and tools </p>

    <p>Critical Thinking skills: effective analysis, reading, writing, presenting, and debating </p>

    <p>Interpersonal Communication skills in organizations </span></p>

    <p>Speech-making, Public Relations, and Interview skills</span></p>

    <p>Power and Influence-making approaches</p>

    <p>Conflict Management and Negotiation principles and skills </p>

    <p>Leadership Styles: Typical vs. Ideal style </p>

    </h6>
    </div>
    <!-- div lignep s'acheve ici -->

    </body>
    </html>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ummm...are you aware that, all other things aside, that code will never work in any browser but MSIE??

    ONLY MSIE uses window.event to get event information.

    And only MSIE 4 required the use of document.all.

    And it probably doesn't make any difference, but your semicolons in here are extraneous and technically an error:
    Code:
    <h6 id="ligne"; onClick="clickEvent1()"; style="font-size: 12pt; line-height: 130%">
    No, I don't see offhand why you get the "Object expected" error.

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,730
    Thanks
    202
    Thanked 2,507 Times in 2,485 Posts
    parentTag1 = window.event.srcElement.parentElement.ta...
    tag2 = window.event.srcElement.parentElement.ta...


    Please follow the posting guidelines and wrap your code in [code] tags. This means use the octothorpe or # button on the toolbar which will insert opening [ code ] and closing [ /code ] tags - omit the spaces. You can edit your previous post, which will get rid of the smilies. Merci!


  •  

    Tags for this Thread

    Posting Permissions

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