【发布时间】:2013-05-05 03:47:19
【问题描述】:
我正在寻找一种解决方案,其中 div 内容会在页面加载时随机更改。很像页面加载时的 JavaScript 图像。我在下面的代码中做了进一步的注释。
我可以在页面加载时使用 JavaScript 对图像等内容进行随机化处理,但这里是 div,我不确定如何更改其中的内容。
<div class="row BSlots">
<div class="Grid_4 fl">
/* This would be the code which would change */
/* For example once it would be <div class="hello"><p>Hi</p></div> and the other <iframe="Link"/> */
</div>
<div class="Grid_4 fr">
<script>Widget2(); /* Don't mind this, loading an actual JS image randomizer here */</script>
</div>
</div>
不使用JS可以实现吗?如果没有,我会很感激一个我可以摆弄的基本例子:)
【问题讨论】:
-
没有脚本,不管是客户端还是服务器端,我想都不会。
-
如果没有 javascript,您将无法做到这一点。您唯一的选择是服务器端,但在每个页面加载后它保持静态。
-
@Daniel 我认为没有 JavaScript 也是可能的。
-
有两种情况。一种是在页面加载后动态。这将需要 javascript。第二个是在服务器端加载的变量中的随机图像。您将需要一种服务器端语言,如 php、asp、jsp。
-
@Benjamin - 喜欢那里的动画 :-) .. 但是 OP 想要放入带有文本和标签的内容,而不是专门的图像(我确实暗示过)。我看不到 CSS 过渡在这里会有帮助。但是谢谢......喜欢它!
标签: javascript html