
help, please, understanding my problem
I have a PHP page that has
require_once("genMyOverlay.js.php");
.
.
.
echo "<body>";
echo "<script language=\"JavaScript\">doit(\"mydiv\");</script><br>";
echo "</body>";
genMyOverlay.js.php contains: createDiv() (see below) that creates a <DIV
ID="mydiv"> and sets it up to overlay a portion of the wbe page and
doit()starts it off.
invoke the web page once and it works like it should. invoke the web page a
second time (and thereafter until a new session) and it gets error:
"doit is not defined"
view the source (at the client browser) and it is identical both (all) times
can anyone please help me understand what is happening?
genMyOverlay.js.php contains
<script language="PHP">
echo "<script language=\"JavaScript\">";
echo "function createDiv()";
echo " {";
.
.
.
echo " }";
echo "function doit(ElementID)";
echo " {";
echo " creatDIV()";
.
.
.
echo " }";
echo "</script>";
</script>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: help, please, understanding my problem
--=-alo6xNGmbS1AfvBztooW
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-02-22 at 09:09 -0600, Stan wrote:
> I have a PHP page that has
> require_once("genMyOverlay.js.php");
> .
> .
> .
> echo "<body>";
> echo "<script language=\"JavaScript\">doit(\"mydiv\");</script><br>";
> echo "</body>";
>
> genMyOverlay.js.php contains: createDiv() (see below) that creates a <DIV
> ID="mydiv"> and sets it up to overlay a portion of the wbe page and
> doit()starts it off.
>
> invoke the web page once and it works like it should. invoke the web page a
> second time (and thereafter until a new session) and it gets error:
> "doit is not defined"
>
> view the source (at the client browser) and it is identical both (all) times
>
> can anyone please help me understand what is happening?
>
> genMyOverlay.js.php contains
> <script language="PHP">
> echo "<script language=\"JavaScript\">";
> echo "function createDiv()";
> echo " {";
> .
> .
> .
> echo " }";
> echo "function doit(ElementID)";
> echo " {";
> echo " creatDIV()";
> .
> .
> .
> echo " }";
> echo "</script>";
> </script>
>
>
>
Going on just that sample, there's no issue. As it works the first time,
there isn't a problem with it not getting included. Have you tried it on
other browsers to see what happens there? Also, Firefox has a brilliant
addon called Firebug, which can show you the contents of included .js
files on your page, which will show up any problems you may have.
Aside from these points, have you a good reason for including a PHP file
that just outputs javascript? Why not just include the .js file as part
of the header?
Also, your script tags need a type attribute:
<script language="javascript" type="text/javascript">
And lastly, instead of lots and lots of echo statements in your page,
have you looked at heredoc and nowdoc syntax in PHP?
echo <<<EOC
lots and lots of output lines go here.
EOC;
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-alo6xNGmbS1AfvBztooW--
Re: help, please, understanding my problem
At 3:15 PM +0000 2/22/10, Ashley Sheridan wrote:
>Also, your script tags need a type attribute:
>
><script language="javascript" type="text/javascript">
>
Actually, you only need this:
<script type="text/javascript">
The language attribute will throw an error in validation.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: help, please, understanding my problem
--=-0lk8R6f+TbR/5UaAI4Q+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Mon, 2010-02-22 at 12:33 -0500, tedd wrote:
> At 3:15 PM +0000 2/22/10, Ashley Sheridan wrote:
> >Also, your script tags need a type attribute:
> >
> ><script language="javascript" type="text/javascript">
> >
>
> Actually, you only need this:
>
> <script type="text/javascript">
>
> The language attribute will throw an error in validation.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
Never thrown an error for me! I guess it depends on what doctype you
use?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-0lk8R6f+TbR/5UaAI4Q+--
Re: help, please, understanding my problem
At 5:32 PM +0000 2/22/10, Ashley Sheridan wrote:
>On Mon, 2010-02-22 at 12:33 -0500, tedd wrote:
>
>>
>>At 3:15 PM +0000 2/22/10, Ashley Sheridan wrote:
>>>Also, your script tags need a type attribute:
>>>
>> ><script language="javascript" type="text/javascript">
>>>
>>
>>Actually, you only need this:
>>
>><script type="text/javascript">
>>
>>The language attribute will throw an error in validation.
>>
>>Cheers,
>>
>>tedd
>>
>
>Never thrown an error for me! I guess it depends on what doctype you use?
I was trying to be discreet.
The "language" attribute has been depreciated. If you use a
"transitional" DOCTYPE, then it won't throw an error -- but the
"language" attribute is outdated and some consider it poor coding
practice to use depreciated attributes.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: help, please, understanding my problem
It works like it is ... once. What I don't understand is why the client
browser(s I have tried it with Firefox and IE 6) can't find the Javascript
function the second time.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: help, please, understanding my problem
--=-g0SkoYWmYMxb9kOSI/Zh
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
On Tue, 2010-02-23 at 05:55 -0600, Stan wrote:
> It works like it is ... once. What I don't understand is why the client
> browser(s I have tried it with Firefox and IE 6) can't find the Javascript
> function the second time.
>
>
>
I've had a look, but I'm not sure what you're trying to achieve with
your Javascript. The .js files seem to be present in the page even after
entering dummy access details into the page. You said you're using PHP
to modify what gets put into the .js file. Are you maybe modifying it in
a way that breaks the javascript?
Thanks,
Ash
http://www.ashleysheridan.co.uk
--=-g0SkoYWmYMxb9kOSI/Zh--
Re: Re: help, please, understanding my problem
On Tue, Feb 23, 2010 at 1:03 PM, Ashley Sheridan
<ash [at] ashleysheridan.co.uk> wrote:
> Are you maybe modifying it in
> a way that breaks the javascript?
>
that would be my guess too... firefox + firebug will often give
accurate error messages for badly formed js.
the error itself is known to be caused by malformed js unable to be
parsed by the browser.
ie(8) does more js syntax nagging than most other browsers.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: help, please, understanding my problem
Thanks all.
I rediscovered DIFF, compared the source for the first and second rendering.
Besides the unique variable names there was also the message ... which
contained imbedded single quote marks. When I changed them to imbedded
double quote marks the problem went away.
""Stan"" <stanleytberry [at] gmail.com> wrote in message
news:11.66.00376.2CE928B4 [at] pb1.pair.com...
> I have a PHP page that has
> require_once("genMyOverlay.js.php");
> .
> .
> .
> echo "<body>";
> echo "<script language=\"JavaScript\">doit(\"mydiv\");</script><br>";
> echo "</body>";
>
> genMyOverlay.js.php contains: createDiv() (see below) that creates a <DIV
> ID="mydiv"> and sets it up to overlay a portion of the wbe page and
> doit()starts it off.
>
> invoke the web page once and it works like it should. invoke the web page
a
> second time (and thereafter until a new session) and it gets error:
> "doit is not defined"
>
> view the source (at the client browser) and it is identical both (all)
times
>
> can anyone please help me understand what is happening?
>
> genMyOverlay.js.php contains
> <script language="PHP">
> echo "<script language=\"JavaScript\">";
> echo "function createDiv()";
> echo " {";
> .
> .
> .
> echo " }";
> echo "function doit(ElementID)";
> echo " {";
> echo " creatDIV()";
> .
> .
> .
> echo " }";
> echo "</script>";
> </script>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php