
我想获取A.html的有些标签内容放到B.html上的合适的input标签内容里用js怎么能获取这个效果?
1个回答
展开全部
两个不同的页面之间js环境是独立的,你需要实现跨页面传递内容。
1、a.html:
<script>
function gotoB()
{
window.location = "b.html?"+document.getElementById("a1").value;
}
</script>
<input type="text" id="a1" value="12345"/>
<a href="javascript:gotoB()">去b.html</a>
2、b.html:
<script>
function getContentFromLink()
{
var str = window.location.search;
if(str.length > 0)
str = str.substring(1);
document.getElementById("b1").value = str;
}
</script>
<input type="text" id="b1" value="" />
<input type="button" onclick="getContentFromLink()" value="点我查看效果" />
1、a.html:
<script>
function gotoB()
{
window.location = "b.html?"+document.getElementById("a1").value;
}
</script>
<input type="text" id="a1" value="12345"/>
<a href="javascript:gotoB()">去b.html</a>
2、b.html:
<script>
function getContentFromLink()
{
var str = window.location.search;
if(str.length > 0)
str = str.substring(1);
document.getElementById("b1").value = str;
}
</script>
<input type="text" id="b1" value="" />
<input type="button" onclick="getContentFromLink()" value="点我查看效果" />
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询