Flash game is ok in IE but in Google Chrome or Firefox the game opens up in a specified window size but the game itself which is flash, is a small image at top left within the window size. for example like placing a postage stamp on top left hand corner of a sheet of A4 paper, instead of the postage stamp filling the whole screen like it does correctly in IE. Code is shown below that launches the games.

<?
/***********************************************************************
GamingCenter
GAME LAUNCHER v1.0
************************************************************************/
Error_Reporting(0);
unset($l);
session_start();
session_register($l);
include ("includes/config.php");
include ("dbcon.php");
if(isset($l)){
if ($mode=="fun" && $l!="guestlogin")
{
$loginkey=md5(rand(00000000000000000,999999999999999999));
$loginkey=strtoupper($loginkey);
$js_username="$l";
$js_password="$p";
mysql_query("INSERT INTO `jsgamingcenter_loginkeys` VALUES('$loginkey', 'PLAY FOR FUN RELOGIN', '$js_username', '$js_password')", $casdb);
$relogin="1";
} }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title><? echo "$casinoname"; ?> Casino/Games</title>
  <style type="text/css">
<!--
.style1 {
    font-size: x-small;
    font-weight: bold;
}
-->
</style>
  <script language="javascript">
  function openerRefresh(){
    //allow refresh of parent window unless parent is closed, if any exception if caught (by changing parent window domain) then do not refresh and close popup
    try {
        if (!window.opener.closed) {
            openerUrl=window.opener.location.href;
            //no need to add refresh=true to the url if its already there
            if (!(openerUrl.indexOf("refresh=true") > -1)) {
                if (openerUrl.indexOf("#") > -1) {
                    openerUrl = openerUrl.replace("index.php","?refresh=true&relogin=<? echo "$relogin"; ?>&loginkey=<? echo "$loginkey"; ?>");
                } else {
                    if(openerUrl.indexOf("?") == -1) {
                        openerUrl += "?refresh=true";
                    } else {
                        openerUrl += "&refresh=true";
                    }
                }
            }
            window.opener.location.href=openerUrl;
        } 
    } catch(e) {   
        self.close();
    } 
}
  </script>
<SCRIPT language="javascript">
// writes the flash embedding tags using javascript, as required by MS's patent-busting IE "update"
function embedSwf(target, swf, base, width, height) {
    d = document.getElementById( target );
    d.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + width + '" height="' + height + '" id="mapcontrols">' +
            '<param name="movie" value="' + swf + '">' +
            '<param name="quality" value="high">' +
            '<param name="menu" value="false">' +
                  '<param name="allowFullScreen" value="true" >' +

            '<param name="base" value="' + base + '">' +
            '<embed src="' + swf + '" menu="false" swLiveConnect="true" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="'  + '" name="mapcontrols" base="' + base + '">' +
            '</embed>' +
            '</object>';
}
</SCRIPT>
    <script type="text/javascript" language="JavaScript">
        function resizeTo(w,h) {
          if (parseInt(navigator.appVersion)>3) {
            if (navigator.appName=="Netscape") {








            } else {
              window.resizeBy(w-document.body.clientWidth, h-document.body.clientHeight);
            }
            self.focus();
          }
        }
      </script>
  </head>
<?
$gamedet=mysql_fetch_array(mysql_query("select * from jsgamingcenter_games where id='$game'", $casdb)); 
$game_status=$gamedet["status"];
$game_id=$gamedet["id"];
$game_name=$gamedet["name"];
$game_width=$gamedet["width"];
$game_height=$gamedet["height"];
$game_location=$gamedet["location"];
$game_basedir=$gamedet["base_directory"];
if($game_id!=$game){
echo "ERROR gc_g1 - Game does not exist!";
exit;
}
if($game_status!="1"){
echo "ERROR gc_g2 - Game not availible!";
exit;
}
if(isset($l)){
$luserdet=mysql_fetch_array(mysql_query("select * from jsgamingcenter_users where login='$l'", $casdb)); 
if ($mode=="real" && $luserdet[24]!="1"){
echo "<div align=\"center\" class=\"style1\">You cannot &quot;Play For Real&quot; because your account is not currently in an active state! </div>";
exit;}}
if(!isset($l)){
if ($mode=="real") {
echo "<div align=\"center\" class=\"style1\">Please log into your $casinoname account in order to start a &quot;Play For Real&quot; Game! </div>";
exit;
}
}
if(isset($l)){
if ($mode=="fun") {
unset($l);
session_destroy();
session_start();
mysql_query("UPDATE jsgamingcenter_users set cash='5000' where login='guestlogin'", $casdb);
$HTTP_SESSION_VARS['l']=guestlogin;
$HTTP_SESSION_VARS['p']=guestlogin;
}
}
if(!isset($l)){
if ($mode=="fun") {
session_start();
mysql_query("UPDATE jsgamingcenter_users set cash='5000' where login='guestlogin'", $casdb);
$HTTP_SESSION_VARS['l']=guestlogin;
$HTTP_SESSION_VARS['p']=guestlogin;
}
}
if(isset($l)){
if ($mode=="real" && $l=="guestlogin") {
echo "<div align=\"center\" class=\"style1\">Please log into your $casinoname account in order to start a &quot;Play For Real&quot; Game! </div>";
exit;
}
}
echo "
<body leftmargin=\"0\" topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" scroll=\"no\" onUnload=\"openerRefresh()\">
<script language=\"javascript\">
        top.resizeTo($game_width, $game_height);
</script>
<span id=\"swfTarget\">
    <script>embedSwf( \"swfTarget\",
                      \"$game_location\",
                      \"$game_basedir\",
                      \"100%\",
                      \"100%\" );
    </script></span>
</body>
";
?>

Dani AI

Generated

Likely causes: the SWF is being inserted into an inline element and the generated <embed> markup is missing width/height attributes — IE is forgiving (it falls back to the classid/object path) while Chrome/Firefox honor the computed layout and show the default tiny plugin rectangle. This combines ’s point about sizing the container with ’s advice to develop for standards-compliant browsers first.

Recommended fixes (minimal, focused):

  • Use a block-level container that can actually take width/height (change the span to a div and ensure html/body have 100% height so percentage heights resolve).
  • Fix the JavaScript that builds the object/embed so both the object and the embed include the passed width and height strings (the original concatenation omits them).
  • Prefer standards markup for modern browsers: an <object type="application/x-shockwave-flash" data="..."> with <param> children, or use a small library (SWFObject) to handle cross-browser differences.

Example (short, corrected pattern):

<style>
html,body { height:100%; margin:0; }
#swfTarget { display:block; width:100%; height:100%; }
</style>

<div id="swfTarget"></div>

<script>
function embedSwf(target, swf, base, width, height) {
  var d = document.getElementById(target);
  d.innerHTML = '<object type="application/x-shockwave-flash" data="' + swf + '" width="' + width + '" height="' + height + '">' +
                '<param name="movie" value="' + swf + '"/>' +
                '<param name="base" value="' + base + '"/>' +
                '<param name="allowFullScreen" value="true"/>' +
                '</object>';
}
</script>

Quick troubleshooting: inspect the inserted element in DevTools to confirm computed width/height, look for JS errors preventing proper string concatenation, and verify the container isn’t constrained by parent CSS. Note: Flash reached end-of-life on December 31, 2020 and modern browsers block/disable it — if this project is being maintained today, planning a migration to HTML5/Canvas/WebGL (CreateJS, Phaser, Pixi, Unity WebGL, etc.) is strongly advised.

Recommended Answers

All 2 Replies

Member Avatar for Member #949455

Flash game is ok in IE but in Google Chrome or Firefox the game opens up in a specified window size but the game itself which is flash, is a small image at top left within the window size.

You need to set the div container or a table by the width so it can adjusted to any pecified window size.

Flash has nothing to do with the browser unless you didn't installed the Flash plugin.

Only CSS code affects the browser appears not Flash

Just to add my two cents to this... If you are developing stuff for use in a browser, I always design for browsers like Firefox and Chrome first. Then I fix/workaround the errors that pop up in IE (because Microshaft doesn't like following standards).

It is usually a lot less work to add a couple of workarounds/hacks for IE than it is to through a bunch of stuff in to get it to work in the other browsers. Luckily we have IE 10, which seems to follow standards more than any other IE version before it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.