Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > onload works in page A but not Page B

Reply
Thread Tools

onload works in page A but not Page B

 
 
DrKen
Guest
Posts: n/a
 
      07-19-2011
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="<pstagrofile
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
 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      07-19-2011
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/
 
Reply With Quote
 
 
 
 
dhtml
Guest
Posts: n/a
 
      07-19-2011
On Jul 19, 2:37*pm, DrKen <(E-Mail Removed)> 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="<pstagrofile


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
 
Reply With Quote
 
Denis McMahon
Guest
Posts: n/a
 
      07-19-2011
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:

<pstagrofile 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
onload -->* no onload marco Javascript 7 06-24-2006 08:39 PM
Why doesn't frameset onload event get called when each of the frames has an onload? adnanx82@gmail.com Javascript 5 05-15-2005 01:58 PM
base.OnLoad called, OnLoad not executed Fabio R. ASP .Net 0 03-25-2005 01:21 PM
<img onload= does not work in FireFox 1.0 but works in IE Luke Venediger Javascript 3 03-08-2005 08:15 PM
window.onload and body.onload differences David Otton Javascript 2 11-04-2004 04:34 PM



Advertisments