Jump to content

Document.write help


scienceguyz
 Share

Recommended Posts

I am working on a website that has several games on it playable by a clicking a button, but I can't get the document.write thing to write the Everybody Edits embed code!What I have so far:

<html><body><script type="javascript">function everybody_edits(){var game=everybody_edits}</script><script type="javascript">function block_miner(){var game=block_miner}</script><script type="javascript">function mebas(){var game=mebas}</script><script type="javascript">function stick_ranger(){var game=stick_ranger}</script><script type="javascript">function powder_game(){var game=powder_game}</script><script type="javascript">function pixelvania(){var game=pixelvania}</script><!-- The following script is to make the game appear--><script type=text/javascript>function show_game()while game=everybody_edits{Document.Write("</div>	    <div style="margin:auto;text-align:center;background:#000000  ;padding:5px;border-top:1px solid #444444;border-bottom:1px solid #444444">		    <div style="margin:auto;width:850px;height:500px;background:url(http://weight-lose.org/browse.php/Oi8vYmV0/YS5ldmVy/eWJvZHll/ZGl0cy5j/b20vaW1n/L2xsLnBu/Zw_3D_3D/b31/) no-repeat center center #000000;border:1px solid #444444;">			    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="850" height="500" id="eetest" align="middle">				    <param name="movie" value="http://r.playerio.com/r/everybody-edits-su9rn58o40itdbnw69plyw/freegame.swf" />				    <param name="quality" value="high" />				    <param name="bgcolor" value="#000000" />				    <param name="play" value="true" />				    <param name="loop" value="true" />				    <param name="wmode" value="window" />				    <param name="scale" value="showall" />				    <param name="menu" value="true" />				    <param name="devicefont" value="false" />				    <param name="salign" value="" />				    <param name="allowScriptAccess" value="always" />				    <param name="allowFullScreen" value="true" />				    <!--[if !IE]>-->				    <object type="application/x-shockwave-flash" data="http://r.playerio.com/r/everybody-edits-su9rn58o40itdbnw69plyw/freegame.swf" width="850" height="500">					    <param name="movie" value="http://r.playerio.com/r/everybody-edits-su9rn58o40itdbnw69plyw/freegame.swf" />					    <param name="quality" value="high" />					    <param name="bgcolor" value="#000000" />					    <param name="play" value="true" />					    <param name="loop" value="true" />					    <param name="wmode" value="window" />					    <param name="scale" value="showall" />					    <param name="menu" value="true" />					    <param name="devicefont" value="false" />					    <param name="salign" value="" />					    <param name="allowFullScreen" value="true" />					    <param name="allowScriptAccess" value="always" />				    <!--<![endif]-->					    <a href="http://www.adobe.com/go/getflash">						    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />					    </a>				    <!--[if !IE]>-->				    </object>				    <!--<![endif]-->			    </object>		    </div>	    </div>")}</script><input type="button" onclick="everybody_edits()"value="Play Everybody Edits" /><input type="button" onclick="block_miner()"value="Play Block Miner" /><input type="button" onclick="mebas()"value="Play Mebas" /><input type="button" onclick="stick_ranger()"value="Play Stick Ranger" /><input type="button" onclick="powder_game()"value="Play Powder Game" /><input type="button" onclick="pixelvania()"value="Play Pixelvania" /><br><br><input type="button" onclick="show_game()"value="Play the game" /></body></html>

Please help!

Link to comment
Share on other sites

document.write although it would be better practice to just have that code hidden somewhere and use javascript to toggle its display. also, I think you want to be assigning the value of game in those functions as a strings. Otherwise game will always be undefined. And an if statement seems more appriopriate, i.e.

if(game == 'everybody_edits'){  //code goes here}

Edited by thescientist
Link to comment
Share on other sites

Note also, that the variable game is local to each function, not global. Declare it in the global space (ie, not inside of any functions):

var game;

and remove the var keyword from all of your assignments within the functions.

And an if statement seems more appriopriate
Or a switch if you'll be writing things for each possible value of game:
switch (game) {   case 'everybody_edits':	  //code	  break;   case 'block_miner':	  //code	  break;   ...}

Edited by ShadowMage
Link to comment
Share on other sites

You're also trying to write a large multiline string with unescaped quotes. Javascript does not support multiline strings, so you need to either put the entire string on one line, or end the string on each line and start it again on the next. You also need to escape all quotes, if the string is surrounded by double quotes then you need to escape any double quote inside the string so that it prints a quote instead of ending the string and causing an error.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...