#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Your House
    Posts
    3
    Rep Power
    0

    Javascript inside php?


    Aight. Here's the code I'm using currently in .html files:

    In <HEAD>
    <script language="JavaScript">
    <!-- Begin
    function popUp(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');");
    }
    // End --></script>

    In <BODY>
    <a href="javascript:PopUp('biloxiblues.htm')">Details</a>

    Now, this code works in HTML. However, when I switch over to PHP, it suddenly fails...any reason for this?
  2. #2
  3. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    40
    ehhh? how do u mean it *suddenly fails*? like the popup script isnt working or its not being executed?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Your House
    Posts
    3
    Rep Power
    0
    Originally posted by roninblade
    ehhh? how do u mean it *suddenly fails*? like the popup script isnt working or its not being executed?
    It's not being executed, sorry. The new window opens, but it comes up with a "page not found" error.
  6. #4
  7. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    40
    test this...
    Code:
    function popUp(URL) { 
      var windowURL = URL;
      day = new Date(); 
      id = day.getTime(); 
      eval("page" + id + " = window.open(windowURL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');"); 
    }
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    14
    This is hard to debug because the code you posted presumably isn't what you're actually using:

    function popUp(URL) {
    <a href="javascript&#58;PopUp

    ..and:

    // End --></script> (you've commented out the </script> tag).

    Try and post the actual (PHP-generated) source.
  10. #6
  11. // no comment
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2001
    Posts
    1,645
    Rep Power
    40
    i was actually able to make it work using the code below ---
    Code:
    <html>
    <head>
    <script language="JavaScript">
    
    function popUp(URL) {
      day = new Date();
      id = day.getTime();
      window.open(URL, 'id', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1');
    }
    
    </script>
    
    <body>
      <a href="javascript:popUp('index.php');">Details</a>
    </body>
    </html>
    i had to remove the eval function. it just wont work with the browsers im using. maybe that's the problem - try removing it from your code and see what happens.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2002
    Location
    Your House
    Posts
    3
    Rep Power
    0

    Drumroll Please...


    Aight, I nailed it down. Everything seems to be working fine now


    Thanks much for the help, all!

IMN logo majestic logo threadwatch logo seochat tools logo