HTML,将iframe src设置为javascript变量

时间:2012-11-30 23:54:18

标签: javascript html iframe document.write

我想在我的另一个网页的网页上显示一个窗口,希望通过iframe。我需要将src设置为javascript变量,这里是代码:

<html>
<head><title>my webpage</title></head>
<SCRIPT language=JavaScript type=text/javascript>
function GoToURL(j) {
var URLis = document.URLframe.Dest.value
document.write("<center><iframe src=\"http://www.example.com\"/ width=1350 height=500     seamless></center>");
    }
</SCRIPT>
<FORM name=URLframe>
<TABLE align=center border=0>

<TBODY>
<TR>
<TD vAlign=center align=middle><BR><INPUT maxLength=50 size=50 
  name=Dest></TD></TR>
<TR>
<TD align=middle>
  <P><INPUT onclick=GoToURL(this) type=button value="                       Go to..                                " name="Go to"></P></TD></TR></TBODY></TABLE></FORM>
</html>

我需要将iframe src设置为变量URL,简单地说。我在html和javascript中都是一个新手,所以请保持尽可能简单。您对将iframe src设置为URLis变量的方法有什么建议或想法吗?

谢谢。

1 个答案:

答案 0 :(得分:4)

试试这个:

var URLis = document.URLframe.Dest.value;
document.write('<center><iframe src="' + URLis + '" width=1350 height=500 seamless></center>');
相关问题