onload works in page A but not Page B

Discussion in 'Javascript' started by DrKen, Jul 19, 2011.

  1. DrKen

    DrKen Guest

    I coded an onload call in the body tag of a page:
    <body id="page-aboutme" onload="executeOmniture()">

    In page A, I know this works, both from running it locally and running
    it as part of an application. In page B, my function does not work
    and I don't get why. I expect code to work the same from place to
    place. I copied from A to B.

    In page B, I have

    <body id="page-aboutme" onload="executeOmniture()" >

    Inside the FORM is

    <INPUT TYPE="HIDDEN" NAME="Email$95Address" AnnType="Text Entry"
    AnnRequired="false" AnnValidateEmail="false" VALUE="<pstag:profile
    value="Individuals.CS-Appl Biographic.Email_Address" poutput="Text" /
    >" SIZE=32 MAXLENGTH=70 id="omniEmail">


    So the id of the item is defined. The function should be called upon
    the onload event.

    Just before the </body> tag:
    <!-- Omniture SiteCatalyst code -->
    <script type="text/javascript">

    alert("Do alerts work?");

    var omniIdentifier = null;
    function executeOmniture()
    {
    omniIdentifier = document.getElementById("omniEmail").value;
    //<![CDATA[
    s.server="home.apu.edu";
    s.channel="Admissions";
    s.pageName="Applications: APS: Start";
    s.hier1="applications,aps";
    alert("omniIdentifier: " + omniIdentifier);
    s.events="event8:APS"+ "TEST" + omniIdentifier;
    var s_code=s.t();if(s_code)document.write(s_code)//-->
    //]]>
    }
    </script>
    <!-- End Omniture SiteCatalyst code -->


    In the JavaScript block, the initial alert works, but I am getting an
    error that the id, omniEmail is not defined. Since this works in
    another page, I can't figure out what I did wrong when I added this.
    Any suggestions how to find it? Thanks.

    Ken
     
    DrKen, Jul 19, 2011
    #1
    1. Advertising

  2. 20.07.2011 00:37, DrKen wrote:

    >Since this works in
    > another page, I can't figure out what I did wrong when I added this.
    > Any suggestions how to find it? Thanks.


    Check out line 42. The error might be there. Or on line 1911.

    Seriously, post the URLs.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Jul 19, 2011
    #2
    1. Advertising

  3. DrKen

    dhtml Guest

    On Jul 19, 2:37 pm, DrKen <> wrote:
    > I coded an onload call in the body tag of a page:
    > <body id="page-aboutme" onload="executeOmniture()">
    >
    > In page A, I know this works, both from running it locally and running
    > it as part of an application.  In page B, my function does not work
    > and I don't get why. I expect code to work the same from place to
    > place.  I copied from A to B.
    >
    > In page B, I have
    >
    > <body id="page-aboutme"  onload="executeOmniture()" >
    >
    > Inside the FORM is
    >
    > <INPUT TYPE="HIDDEN" NAME="Email$95Address" AnnType="Text Entry"
    > AnnRequired="false" AnnValidateEmail="false" VALUE="<pstag:profile


    What sort of markup is that? It's not HTML.

    > value="Individuals.CS-Appl Biographic.Email_Address" poutput="Text" /


    What is that slash there? Perhaps the parser stops there and does not
    parse the id.

    >
    > >" SIZE=32 MAXLENGTH=70 id="omniEmail">

    >
    > So the id of the item is defined.  The function should be called upon
    > the onload event.
    >
    > Just before the </body> tag:
    > <!-- Omniture SiteCatalyst code -->
    > <script type="text/javascript">
    >
    >     alert("Do alerts work?");
    >
    >     var omniIdentifier = null;
    >   function executeOmniture()
    >         {
    >           omniIdentifier = document.getElementById("omniEmail").value;
    > //<![CDATA[


    CDATA would make sense for XML. The markup isn't XHTML -- way too many
    errors.

    >         s.server="home.apu.edu";
    >         s.channel="Admissions";
    >         s.pageName="Applications: APS: Start";
    >         s.hier1="applications,aps";
    >         alert("omniIdentifier: " + omniIdentifier);
    >         s.events="event8:APS"+ "TEST" + omniIdentifier;
    >         var s_code=s.t();if(s_code)document.write(s_code)//-->
    > //]]>}
    >
    > </script>
    > <!-- End Omniture SiteCatalyst code -->
    >

    Omniture, I am sorry to say, is unreliable and badly coded. ForeSee
    results is about the same.


    > In the JavaScript block, the initial alert works, but I am getting an
    > error that the id, omniEmail is not defined. Since this works in
    > another page, I can't figure out what I did wrong when I added this.
    > Any suggestions how to find it?  Thanks.


    Strong expectations about what the script should do can't be made when
    the underlying document is using invalid HTML.
    --
    Garrett
     
    dhtml, Jul 19, 2011
    #3
  4. On Tue, 19 Jul 2011 15:00:55 -0700, dhtml wrote:

    > What is that slash there? Perhaps the parser stops there and does not
    > parse the id.


    I think the slash is terminating the <pstag that's being handled by some
    sort of pre-processor, and my assumption based on previous posts by the
    same poster would be that:

    <pstag:profile value="Individuals.CS-Appl Biographic.Email_Address"
    poutput="Text" />

    is, for some pre-processor that the OP uses, broadly equivalent to

    <?php /* run a database query to get an email address and then echo the
    email address */ ?>

    ie, it fills in the value of the hidden field with an email address.

    Of course, it only does that if the pre-processor is working properly,
    and in the past the op has shown a misunderstanding that the pre-
    processor code is executed client side after he downloads the page, when
    I'm pretty sure that to work it has to be executed server side before the
    page is sent to the browser, so this could be another example of the op
    testing a file that is intended to go through the pre-processor by
    opening it directly as a file in his browser.

    Pre-processor hasn't parsed the code, so he's got a mishmash of crud.

    Rgds

    Denis McMahon
     
    Denis McMahon, Jul 19, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Fabio R.
    Replies:
    0
    Views:
    842
    Fabio R.
    Mar 25, 2005
  2. F. GEIGER
    Replies:
    3
    Views:
    813
    F. GEIGER
    Aug 6, 2004
  3. David Otton

    window.onload and body.onload differences

    David Otton, Nov 4, 2004, in forum: Javascript
    Replies:
    2
    Views:
    614
    Martin Honnen
    Nov 4, 2004
  4. Luke Venediger
    Replies:
    3
    Views:
    165
  5. Replies:
    5
    Views:
    316
    Thomas 'PointedEars' Lahn
    May 15, 2005
Loading...

Share This Page