我有一个javascript变量(siteContents)我想添加一个动态div与超级链接弹出它。动态div有动态div id和动态帧url。激活动态div的按钮也有动态名称和动态值。
有没有人能告诉我如何将动态div及其按钮添加到siteContents变量?
这是我要添加到siteContents变量的动态div:
<div id="mangodiv" style="display:none">
<li>
<iframe src="http://www.mysite.com/?itemid=mango&bgcolor=white" style="border: medium none;" height="300" width="450"></iframe><br>
</li>
</div>
这是激活上述动态div的超链接。我想添加这个我的siteContents变量:
<li><a href="#" onClick="divwin=dhtmlwindow.open('divbox', 'div', 'mangodiv', 'mango', 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1'); return false"><b>popup div</b></a></li>
这是激活弹出式div的部分:
<head>
<link rel="stylesheet" href="windowfiles/dhtmlwindow.css" type="text/css" />
<script type="text/javascript" src="windowfiles/dhtmlwindow.js">
</script>
</head>
当前变量: var itemName ='mango'
var siteContents = "<li>"
+"<iframe src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTeUusgzharBX4HTwmQHNZOimpaCGRBx4CLKNJAiLjUVi12VN66' height=200 width=200 style='border: none;'></iframe><br>"
+"<div class='details'>"
+"<div class='title'>"
+"<a href='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTeUusgzharBX4HTwmQHNZOimpaCGRBx4CLKNJAiLjUVi12VN66' target=\"_blank\"'>"+itemName+"</a><br>"
+"</div></div></li>";
document.getElementById("myDiv").innerHTML += siteContents;
<ul id="myDiv"></ul>
我试过这个但是所有隐藏的div都显示在点击按钮之前!
var itemName = 'mango'
var siteContents = "<li>"
+"<iframe src='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTeUusgzharBX4HTwmQHNZOimpaCGRBx4CLKNJAiLjUVi12VN66' height=200 width=200 style='border: none;'></iframe><br>"
+"<div class='details'>"
+"<div class='title'>"
+"<a href='https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcTeUusgzharBX4HTwmQHNZOimpaCGRBx4CLKNJAiLjUVi12VN66' target=\"_blank\"'>"+itemName+"</a><br>"
+= " <div id=\"mangodiv\" style=\"display:none\">";
+= "<li>";
+= "<iframe src=\"http:\/\/www.mysite.com\/?itemid=mango&bgcolor=white\" style=\"border: medium none;\" height=\"300\" width=\"450\"><\/iframe><br>";
+= "<\/li>";
+= "<\/div> ";
+= "<a href=\"#\" onClick=\"divwin=dhtmlwindow.open('divbox', 'div', 'mangodiv', 'mango', 'width=450px,height=300px,left=200px,top=150px,resize=1,scrolling=1'); return false\"><b>popup div<\/b><\/a><\/li>";