I want to put two miniclip.com games in my website but they both start at the same time.
How can I get them to start separately when the user clicks them?
views:
43answers:
1There are ways to do this with JavaScript. One is to display a link in a div, and have the link's onclick
script replace the link itself with the HTML that embeds the game. Then when you click the link, the game loads and displays. For instance:
<div id="game1Container">
<a href="#" onclick="document.getElementById('game1Container').innerHTML = 'GAME HTML GOES HERE'; return false;">Start the game!</a>
</div>
You would replace the text GAME HTML GOES HERE
with your <embed>
tag, or whatever it is you're already using to load the game. But, it may not work right unless you take that HTML and encode it properly so that <
becomes <
, >
becomes >
, and "
becomes "
. I see you tagged this question with the "dreamweaver" tag. Dreamweaver probably has such a feature, so look around in there. There are also websites that can do this encoding for you (or, there must be).
Doug Neiner pointed out in a comment: If you want to make it really nice, you can replace Start the game!
with an <img>
that displays a screenshot of the game, overlaid with some text like "Play". This is like how YouTube displays a screenshot of a video, and you click to start it.