注册 登录
编程论坛 JavaScript论坛

innerhtml引用地址的问题

wstcl 发布于 2017-12-11 16:02, 2152 次点击
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
<script>
function intialhtmleditor(htmleditor)
{
    htmleditor.document.designMode = "on";
        
}

function getinnertext(htmleditor1,htmleditor2,mytxtarea)
{
    htmleditor1.document.body.innerHTML="<img src=\"../aa.jpg\">";
    htmleditor2.document.body.innerText=htmleditor1.document.body.innerHTML;
    mytxtarea.value=htmleditor1.document.body.innerHTML;
    alert(htmleditor1.document.body.innerHTML);
        }
        
</script>


</head>

<body onload="intialhtmleditor(frame1);intialhtmleditor(frame2)">
<form>
<div style=";background-color:#FF00FF">
<iframe id="frame1" style="width:500; height:300;background-color:#FF00FF" ></iframe>
<iframe id="frame2" style="width:500; height:300;background-color:#FF00FF"></iframe>
</div>
<div>
<input type="button" value="
btn1" onclick="getinnertext(frame1,frame2,txt1)">
</div>
<textarea id="txt1"></textarea>
</form>
<p>&lt;&gt;</p>
<img src="../aa.jpg">
</body>

</html>
以上的代码,我第一次在innerHTML中输入了一个相对地址,但运行后,输出innerHTML变成绝对地址,这个怎么解决,我要的效果是如果是输入的是相对地址,输出后仍是相对地址
0 回复
1