代码上来
test1.php
<html>
<head>
<script>
function ff()
{document.getElementById('div1').innerHTML="<a href = 'test2.php?abc=\'>nihao</a>";}
</script>
</head><body onload="ff()">
<div id="div1"><div><!--<a href="test2.php?abc=\">你好</a>
-->此部分注销,链接部分在js部分实现
</body>
</html>
test2.php<html><?php
if(isset($_GET["abc"]))
{
$aa=$_GET["abc"];
}?>
<body>
<input type="text" value="<?php echo $aa;?>">
</body>
</html>
test1.php
<html>
<head>
<script>
function ff()
{document.getElementById('div1').innerHTML="<a href = 'test2.php?abc=\'>nihao</a>";}
</script>
</head><body onload="ff()">
<div id="div1"><div><!--<a href="test2.php?abc=\">你好</a>
-->此部分注销,链接部分在js部分实现
</body>
</html>
test2.php<html><?php
if(isset($_GET["abc"]))
{
$aa=$_GET["abc"];
}?>
<body>
<input type="text" value="<?php echo $aa;?>">
</body>
</html>
<head>
<script>
function ff()
{ document.getElementById('div1').innerHTML=" <a href = 'test2.php?abc=\'>nihao </a>"; }
</script>
</head> <body onload="ff()">
<div id="div1"> <div>
</body>
</html>
这样值能传过去?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function ff()
{
var temp = encodeURIComponent('%5C').replace(/</g,'<').replace(/>/g,'>');
document.getElementById('div1').innerHTML="<a href = 'test2.php?abc="+temp+"&AA=FF'>nihao</a>";
alert(document.getElementById('div1').innerHTML);}
</script>
</head><body onload="ff()">
<div id="div1"><div></body>
</html>只要把\符号按照%5C的替换。就没有问题了
关键是。。这个\是我从后台读出的数据,而且后台是用CGI写的用alert弹出获取的数据就是\这个符号。。不是%5C所以请教一下,如何转移\这个字符那???
传不过去啊、、、、、、、后来发现用%5C才可以啊
<form name="form0" action="test2.php" method="get" style="margin:0px">
<input type="hidden" id="abc" name="abc" value="\">
<a href="javascript:form0.submit()"></a>
</form>
<div>hidden元素可以用js增加修改