<script>
var test = [
"<a href='#' >1</a>",
"<a href='' >2</a>",
"<a href='' >3</a>",
"<a href='#' >4</a>",
"<a href='' >5</a>",
"<a href='' >6</a>"
];
var a = test[Math.floor(Math.random() * test.length)];
document.write(a);
</script>
<?php
$mes= "<script>document.write(a)</script>";
?>
我把$mes 传到另一个php页面是<script>document.write(a)</script>
,无法调用,苦求解决方法。
如果是多页面应用。
那么你可以在
querystring
中传,在后端重新输出变量到前端.http://url/a?key=value
如果是单页面应用,建议使用History API
pushState
popState
和replaceState