Won't work on FireFox

Discussion in 'Javascript' started by Alex, Oct 16, 2006.

  1. Alex

    Alex Guest

    Something is wrong, the </script> tag in the string for some reason is
    the cause from what I can figure. When I remove it, it runs but not as
    it should since it is a broken HTML then.

    <html><head></head><body>
    <script language="javascript">
    function showme(){
    a=window.open("","Thank You","status=1,width=350,height=150");
    a.document.write('<html><body><img
    src="http://www.google.com/intl/en/images/logo.gif"><script
    language="javascript">window.location="http://www.aol.com"</script></body></html>');

    a.document.close();}
    showme();
    </script>
    </body></html>
    Alex, Oct 16, 2006
    #1
    1. Advertising

  2. The JS interpreter sees the </script> inside your string and closes the
    script. This may not be the Right Thing, but a simple workaround would
    be to replace </script> with </'+'script inside the string.

    Alex wrote:
    > Something is wrong, the </script> tag in the string for some reason is
    > the cause from what I can figure. When I remove it, it runs but not as
    > it should since it is a broken HTML then.
    >
    > <html><head></head><body>
    > <script language="javascript">
    > function showme(){
    > a=window.open("","Thank You","status=1,width=350,height=150");
    > a.document.write('<html><body><img
    > src="http://www.google.com/intl/en/images/logo.gif"><script
    > language="javascript">window.location="http://www.aol.com"</script></body></html>');
    >
    > a.document.close();}
    > showme();
    > </script>
    > </body></html>
    Joshie Surber, Oct 16, 2006
    #2
    1. Advertising

  3. Joshie Surber wrote:

    > The JS interpreter sees the </script> inside your string and closes the
    > script. This may not be the Right Thing,


    It is "the right thing", and there are further errors in the markup that the
    validator would pick up.

    > but a simple workaround would
    > be to replace </script> with </'+'script inside the string.


    Simpler would be: <\/script>


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Oct 16, 2006
    #3
  4. On Oct 16, 2:17 pm, "Joshie Surber" <> wrote:
    > The JS interpreter sees the </script> inside your string and closes the
    > script. This may not be the Right Thing, but a simple workaround would
    > be to replace </script> with </'+'script inside the string.


    And that can still cause errors. It's not the "JS interpreter" but
    rather the HTML parser that looks, and it isn't looking for </script>,
    it can simply look for </ and end the script block.

    The "correct" solution is to escape the / in the tag:

    <\/script>

    --
    Randy
    One Dumm Hikk, Oct 17, 2006
    #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. Chad
    Replies:
    4
    Views:
    8,308
  2. Altman
    Replies:
    2
    Views:
    846
    Altman
    Feb 14, 2007
  3. Nathan Sokalski

    Why won't the following work in FireFox?

    Nathan Sokalski, Oct 17, 2007, in forum: ASP .Net
    Replies:
    11
    Views:
    2,032
    David Mark
    Oct 18, 2007
  4. LRW
    Replies:
    5
    Views:
    112
    Dr John Stockton
    Dec 3, 2004
  5. LAshooter

    Javascript won't work in Firefox

    LAshooter, Jun 27, 2005, in forum: Javascript
    Replies:
    5
    Views:
    121
    Thomas 'PointedEars' Lahn
    Jul 15, 2005
Loading...

Share This Page