当用户点击时启动 Flash 游戏
我想在我的网站上放置两个 miniclip.com 游戏,但它们同时启动。
当用户单击它们时,如何让它们单独启动?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有多种方法可以使用 JavaScript 来做到这一点。一种是在 div 中显示链接,并让链接的
onclick
脚本将链接本身替换为嵌入游戏的 HTML。然后,当您单击链接时,游戏将加载并显示。例如:您可以将文本
GAME HTML GOES HERE
替换为标记,或者您已用于加载游戏的任何内容。但是,除非您采用 HTML 并对其进行正确编码,以便
<
变为<
,,否则它可能无法正常工作>
变为>
,"
变为"
。我看到您用“标记了这个问题” Dreamweaver”标签。Dreamweaver 可能有这样的功能,所以看看那里。也有网站可以为你做这种编码(或者,一定有)。DougNeiner 在评论中指出:如果你想制作它非常好,您可以将
Start the game!
替换为,它会显示游戏的屏幕截图,上面覆盖一些诸如“Play”之类的文字。 YouTube 如何显示视频的屏幕截图,然后您单击即可启动它。
There 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: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.