HTML,将iframe src设置为一个javascript变量 [英] HTML, set iframe src as a javascript variable

查看:146
本文介绍了HTML,将iframe src设置为一个javascript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 < html> 
< head>< title>我的网页< / title>< / head>
< SCRIPT language = JavaScript type = text / javascript>
函数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>< /表>< / FORM>
< / html>

我需要将iframe src设置为变量URLis,我在html和javascript中都有些新鲜感,所以请尽量简单。对于将iframe src设置为URLis变量的方式,您有任何建议或想法吗?

谢谢。

解决方案

试试这个:

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


I would like to display a window in my webpage of another webpage, hopefully via iframe. I need to set the src as a javascript variable, here is the code:

<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>

I need to set the iframe src to the variable URLis, simply put. I am somewhat of a newb in both html and javascript, so please keep as simple as possible. Do you have any suggestions or ideas for a way to set the iframe src as URLis variable?

Thank you.

解决方案

Try this:

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

这篇关于HTML,将iframe src设置为一个javascript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆