我试图通过网址传递javascript变量

时间:2015-02-13 12:49:47

标签: javascript html iframe

我试图通过URL传递java脚本变量值,而URL用于加载i-frame这里我的代码

var child_id = 4;

$(newelement).html('<iframe id="becky_bunnyQ1" style="width:92%;height:100%;display:block;position:absolute;border: none;padding-left: 4%;" scrolling="no" src="pages/page20/index.html?id="'+child_id+'></iframe>');

1 个答案:

答案 0 :(得分:1)

设置src属性时出错。应该是:

$(newelement).html('<iframe id="becky_bunnyQ1" 
style="width:92%;height:100%;display:block;position:absolute;border: 
none;padding-left: 4%;" scrolling="no" 
src="pages/page20/index.html?id='+child_id+'"></iframe>');