【发布时间】:2013-04-28 06:44:02
【问题描述】:
所有,我想在 jsp 中使用 javascript 创建一个 html 对象 页面,但 'alert(GameObject1.loginurl);'将提醒“未定义”。
我在下面的代码中是否有一些错误? 'obj.appendChild' 似乎失败了。但是为什么?
var obj;
try {
obj = document.createElement("object");
obj.id = "GameObject1";
obj.name = "JavaGameObject1";
obj.setAttribute("classid", "clsid:72E6F181-D1B0-4C22-B0D7-4A0740EEAEF5");
obj.width = 640;
obj.height = 526;
var loginurl = document.createElement("param");
loginurl.setAttribute("name", "loginurl");
loginurl.setAttribute("value", "xx.xx.xx.xx:8080");
obj.appendChild(loginurl);
document.body.appendChild(obj);
alert(GameObject1.loginurl);
} catch (e) {
alert("Exception:" + e.message);
}
【问题讨论】:
-
你希望从
GameObject1.loginurl得到什么?
标签: javascript html object appendchild param