SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 29 of 29
  1. #26
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is my code which is an iframe its modified so onpage load it appears for 3 seconds then closes:

    joinroom.php:
    PHP Code:
    <?php
    include "../conf/db_connect.php";
    $roomid $_GET['roomID'];

    $query3 mysql_query("SELECT * FROM member WHERE UserName = '$myuser' ")
    or die(
    "Could not insert data because ".mysql_error());
    $qry3 mysql_fetch_array$query3 );

    $query mysql_query("SELECT * FROM room WHERE RoomID = '$roomid' ")
    or die(
    "Could not insert data because ".mysql_error());
    $qry mysql_fetch_array$query );

    if ( 
    $type == guest ) {
    if ( 
    $qry[RoomType] == ) {
    ?>
    <body>
    <head>
    </head>
    <body>
    <script type='text/javascript'>
    function closeMyPopup() {
      document.getElementById("mypopup").style.display = "none";
    }

    function myPopupRelocate() {
      var scrolledX, scrolledY;
      if( self.pageYOffset ) {
        scrolledX = self.pageXOffset;
        scrolledY = self.pageYOffset;
      } else if( document.documentElement && document.documentElement.scrollTop ) {
        scrolledX = document.documentElement.scrollLeft;
        scrolledY = document.documentElement.scrollTop;
      } else if( document.body ) {
        scrolledX = document.body.scrollLeft;
        scrolledY = document.body.scrollTop;
      }

      var centerX, centerY;
      if( self.innerHeight ) {
        centerX = self.innerWidth;
        centerY = self.innerHeight;
      } else if( document.documentElement && document.documentElement.clientHeight ) {
        centerX = document.documentElement.clientWidth;
        centerY = document.documentElement.clientHeight;
      } else if( document.body ) {
        centerX = document.body.clientWidth;
        centerY = document.body.clientHeight;
      }

      var leftOffset = scrolledX + (centerX - 250) / 2;
      var topOffset = scrolledY + (centerY - 200) / 2;

      document.getElementById("mypopup").style.top = topOffset + "px";
      document.getElementById("mypopup").style.left = leftOffset + "px";
    }

    function fireMyPopup() {
      myPopupRelocate();
      document.getElementById("mypopup").style.display = "block";
      document.body.onscroll = myPopupRelocate;
      window.onscroll = myPopupRelocate;
      window.setTimeout("closeMyPopup()", 3000);
    }

    document.body.onload = window.setTimeout("fireMyPopup()", 0);
    </script>
    <div id="mypopup" name="mypopup">
    <style type="text/css">
    #mypopup2
    {
    position:absolute;
    left:300px;
    top:0px;
    z-index:2;
    width: 179px;
    height: 36px;
    display: block;
    border:1px #000000 solid;
    background-color:#990000;
    }
    </style>
    <div id="mypopup2">This is another popup</div>

    </div>
    </body>
    </html>
    <?php
    }
    }
    ?>

    <?php
    $result2 
    mysql_query("SELECT * FROM onlineusers WHERE RoomID = '$qry[RoomID]'");
    $num_rows mysql_num_rows($result2);

    if ( 
    $type == guest ) {
    if ( 
    $qry[RoomType] == ) {
    if (
    $num_rows >= $qry[RoomLimit]) {
    ?>
         <script type="text/javascript"> 
            alert ("Room is full, please try again!") 
          </script>
    <?php
    }
    else
    {

    $query3 "UPDATE onlineusers SET RoomID = '$roomid' WHERE UserName = '$myuser'";
    mysql_query($query3);
    ?>
    <body onload="parent.chatframe.document.getElementById('TypicalPlayerApplet').roomID(<?= $roomid ?>); return false;">
    <?php
    }
    }
    }
    ?>


    <?php
    $result2 
    mysql_query("SELECT * FROM onlineusers WHERE RoomID = '$qry[RoomID]'");
    $num_rows mysql_num_rows($result2);

    if ( 
    $qry3[MemberType] == ) {
    if (
    $num_rows >= $qry[RoomLimit]) {
    ?>
         <script type="text/javascript"> 
            alert ("Room is full, please try again!") 
          </script>
    <?php
    }
    else
    {

    $query3 "UPDATE onlineusers SET RoomID = '$roomid' WHERE UserName = '$myuser'";
    mysql_query($query3);
    ?>
    <body onload="parent.chatframe.document.getElementById('TypicalPlayerApplet').roomID(<?= $roomid ?>); return false;">
    <?php
    }
    }
    ?>


    <?php
    $result2 
    mysql_query("SELECT * FROM onlineusers WHERE RoomID = '$qry[RoomID]'");
    $num_rows mysql_num_rows($result2);

    if ( 
    $qry3[MemberType] == ) {

    $query3 "UPDATE onlineusers SET RoomID = '$roomid' WHERE UserName = '$myuser'";
    mysql_query($query3);
    ?>
    <body onload="parent.chatframe.document.getElementById('TypicalPlayerApplet').roomID(<?= $roomid ?>); return false;">
    <?php
    }
    ?>


    <?php
    $result2 
    mysql_query("SELECT * FROM onlineusers WHERE RoomID = '$qry[RoomID]'");
    $num_rows mysql_num_rows($result2);

    if ( 
    $qry3[MemberType] == ) {

    $query3 "UPDATE onlineusers SET RoomID = '$roomid' WHERE UserName = '$myuser'";
    mysql_query($query3);
    ?>
    <body onload="parent.chatframe.document.getElementById('TypicalPlayerApplet').roomID(<?= $roomid ?>); return false;">
    <?php
    }
    ?>


    <?php
    $result2 
    mysql_query("SELECT * FROM onlineusers WHERE RoomID = '$qry[RoomID]'");
    $num_rows mysql_num_rows($result2);

    if ( 
    $qry3[MemberType] == ) {

    $query3 "UPDATE onlineusers SET RoomID = '$roomid' WHERE UserName = '$myuser'";
    mysql_query($query3);
    ?>
    <body onload="parent.chatframe.document.getElementById('TypicalPlayerApplet').roomID(<?= $roomid ?>); return false;">
    <?php
    }
    ?>
    Animated Chatrooms - www.121chatrooms.net

  2. #27
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, what a mess :-)

    You have a body tag above the head tag, which needs to be removed.

    You have the DIV called "mypopup", which isn't closed, and therefore the next DIV (mypopup2) is nested inside it.

    You're PHP below </html> seems to be generating another body tag dynamically, which becomes pointless because it's outside the HTML and therefore will be ignored by the browser anyway.

    Once you get all of that fixed, let's consider the other problem. If this is the contents of your IFRAME then, you are putting the code for your popup in the wrong place. It must go inside the document that calls the IFRAME. Refer back to my example.

    The best thing when troubleshooting something like this, is to get rid of all the PHP and all the javascript then build it again, element by element. Once you're sure the layout works in html/CSS, then you can start adding your Javacript to show/hide your popup, then you can add your PHP.

    That way, you can always figure out what is causing the problem.
    But like i said, first you need to clean up that code within the IFRAME. Then you need to move the popup divs and their CSS to the main document.

    Keep at it!
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!

  3. #28
    SitePoint Guru
    Join Date
    Sep 2007
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i cant transfer it to the main document because the code above wont work because that code shows the output on load for 3 seconds then closes automaticly
    Animated Chatrooms - www.121chatrooms.net

  4. #29
    SitePoint Guru kish's Avatar
    Join Date
    Jun 2003
    Location
    UK
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I should have also mentioned that ultimately, all of that javascript needs to be moved to the main document too, along with the popup div and css for the popup.
    Both the CSS and javascript should go between <head></head>.
    Fast Fwd Multimedia
    Web, IT & Cloud Computing Consultancy
    Currently looking for web freelancers. Get in touch!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •