IE6 and .js include problem?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Randy Webb

    #16
    Re: IE6 and .js include problem?

    Thomas 'PointedEars' Lahn wrote:
    [color=blue]
    > Randy Webb wrote:
    >[color=green]
    >>Thomas 'PointedEars' Lahn wrote:
    >>[color=darkred]
    >>>Randy Webb wrote:
    >>>
    >>>>Thomas 'PointedEars' Lahn wrote:
    >>>>
    >>>>>>To solve it, I had to use PHP as:
    >>>>>><script > <? include ('myfile.js'); ?> </script>
    >>>>>
    >>>>>This will cause a server-side script error.
    >>>>
    >>>>Think first, code second, test third, post to News fourth.
    >>>>It does *not* cause server side script errors.
    >>>
    >>>But it is likely to and thus it is bad practice. The JavaScript
    >>>only needs to contain "<?" or "<?php" (for whatever reason) and
    >>>the hypertext preprocessor will parse it.[/color]
    >>
    >>Perhaps you should gain access to a PHP-enabled server and test it out.[/color]
    >
    >
    > I *have* already access to a PHP-enabled server at http://localhost/
    > and I am well-versed in PHP, thank you.[/color]

    Obviously not, or you would realize that the only files that the PHP
    parser parses are files that are dictated in the configuration files for
    PHP to process, and by default .js files are not parsed, so any PHP
    commands in a .js file will not be parsed.
    [color=blue]
    >[color=green]
    >>This code:
    >>
    >><script> <?php include ('blank1.js'); ?> </script>
    >>
    >>And in blank1.js:
    >>
    >>notLoaded = false;
    >><? ... ?>
    >><?php ... ?>
    >>
    >>Causes *NO* PHP errors, it throws the appropriate JS errors though.[/color]
    >
    >
    > Of course. I was referring to accidental character sequences in
    > JavaScript code. Don't be stupid![/color]

    You said it would cause an error, I proved you wrong. I would hardly
    call that "being stupid".
    [color=blue]
    >[color=green]
    >>Perhaps you should peruse the www.php.net site and learn how it handles
    >>the include statement.[/color]
    >
    >
    > Perhaps you should create test cases which reflect what I am saying.[/color]

    No, I won't create test cases to back up your arguments, I provided one
    that shows that you are utterly wrong. So, let me repeat what I said.
    Peruse the PHP site and learn how the include statement works.



    --
    Randy
    Chance Favors The Prepared Mind
    comp.lang.javas cript FAQ - http://jibbering.com/faq/

    Comment

    • Randy Webb

      #17
      Re: IE6 and .js include problem?

      Thomas 'PointedEars' Lahn wrote:
      [color=blue]
      > lallous wrote:
      >[color=green][color=darkred]
      >>>This should read
      >>>
      >>> <script type="text/javascript" src="myfile.js" ></script>[/color]
      >>
      >>That doesn't and didn't help.
      >>
      >>This is sometimes happening with images, it seems IIS5 is not
      >>functioning properly or serving files all the time.[/color]
      >
      >
      > That is likely. Without the source code
      > of myfile.js, nobody can tell for sure.
      >
      >[color=green][color=darkred]
      >>>>To solve it, I had to use PHP as:
      >>>>
      >>>><script> <? include ('myfile.js'); ?> </script>
      >>>
      >>>This will cause a server-side script error. What
      >>>do you think PHP will do with _J(ava)Script_ code?[/color]
      >>
      >>That works,[/color]
      >
      >
      > *Sometimes* it does.[/color]

      No, it *always* works. Learn what you are talking about.
      [color=blue]
      >[color=green]
      >>you should have known that if you know a little about
      >>PHP's include() mechanism.[/color]
      >
      >
      > YMMD. You are clearly not to teach me PHP, dearie.[/color]

      Somebody needs to as you clearly have no understanding of how the
      include works in PHP.

      --
      Randy
      Chance Favors The Prepared Mind
      comp.lang.javas cript FAQ - http://jibbering.com/faq/

      Comment

      • Thomas 'PointedEars' Lahn

        #18
        Re: IE6 and .js include problem?

        Randy Webb wrote:[color=blue]
        > Thomas 'PointedEars' Lahn wrote:[color=green]
        >> lallous wrote:[color=darkred]
        >>>>> To solve it, I had to use PHP as:
        >>>>>
        >>>>> <script> <? include ('myfile.js'); ?> </script>
        >>>>
        >>>> This will cause a server-side script error. What
        >>>> do you think PHP will do with _J(ava)Script_ code?
        >>>
        >>> That works,[/color]
        >>
        >> *Sometimes* it does.[/color]
        >
        > No, it *always* works. Learn what you are talking about.[/color]

        foo.js:

        function foo(somehow_I_m ade, a_typo_here)
        {
        if (somehow_I_made <? a_typo_here) // it will cause trouble
        {
        alert(42);
        }
        }

        bar.php parsed by PHP (with short_open_tag = true
        and error_reporting >= E_ERROR in php.ini):

        <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">
        <html>
        <head>
        <title>Test Case: How PHP Includes Can Fail</title>

        <!-- Dublin Core Metadata, see http://dublincore.org/ for details
        -->
        <meta name="DC.Title" content="How PHP Includes Can Fail">
        <meta name="DC.Subjec t" content="Test case">
        <meta
        name="DC.Descri ption"
        content="A tribute to all ignorants of the pitfalls of server-side
        scripting">
        <meta
        name="DC.Creato r"
        content="cljs@P ointedEars.de (Thomas Lahn)">
        <meta name="DCTERMS.c reated" content="2004-07-12T05:20+02:00" >
        <meta name="DC.Type" content="Text">
        <meta name="DC.Format " content="text/html">
        <meta name="DC.Langua ge" content="en">
        <meta name="DC.Rights " content="Publis hed under the GNU GPL v2">
        <meta
        name="DCTERMS.a udience"
        content="J(ava) Script and PHP programmers">

        <script type="text/javascript">
        <? include('foo.js '); ?>
        </script>
        </head>

        <body>
        <p>This text will not be displayed.</p>
        </body>
        </html>

        And one can think of of less obvious examples, using
        ECMAScript Regular Expression literals which would be
        valid J(ava)Script code, for example.


        PointedEars, Score adjusted

        Comment

        Working...