Quick Javascript Help

Discussion in 'Design and Graphics' started by Grimace, Aug 22, 2006.

  1. macrumors 68040

    Grimace

    Joined:
    Feb 17, 2003
    Location:
    with Hamburglar.
    #1
    Hi all, I am pulling my hair out trying to figure out why my basic javascript code for a popup window won't work with Firefox or IE (it works fine with Safari!) A blank page opens in Firefox (view source reveals just the <html><head><body> tags). Page can't be displayed shows up in IE.
    ---------------------------------------------------------------
    In the <head> section:

    <script language="javascript">

    function test(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=500');");
    }
    </script>
    --------------------------------------------------------------

    In the <body> section:

    <a href="javascript:test('http://www.google.com')">Google</a>
     
  2. macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #2
    stop evaluating ;)

    Code:
    <script>
    function test(URL)
    {
      var id=new Date().getTime();
      var w=window.open(URL,id,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=550,height=500');
    }
    
    </script>
    <a href="javascript:test('http://www.google.com')">url</a>
    
    Javascript is not strictly-typed, use this to your advantage ;)
     
  3. thread starter macrumors 68040

    Grimace

    Joined:
    Feb 17, 2003
    Location:
    with Hamburglar.
    #3
    hmm....I still get nothing. :( Shouldn't the </script> show up in a similar font (I'm using DW) like the first one?
     
  4. macrumors 6502a

    Palad1

    Joined:
    Feb 24, 2004
    Location:
    London, UK
    #4
    There was a typo, add a single quote before toolbar and you're set to go :)
     

Share This Page