[英]How to use tinybox in jsp
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<script type="text/javascript" src="tinybox.js"></script>
</head>
<body>
<label>Name :</label><input type="text" id="name" onclick="tiny();"/>
<script type="text/javascript">
function tiny(show)
{
TINY.box().show(ajax.html,show,300,150,true,500) ;
}
</script>
</body>
上面的代码在jsp中不起作用。请帮助我如何使用jsp.ajax.html页面中的tinybox已存在于此页面的同一位置。
可能有两个原因
1.与使用JSP一样 ,您需要使用request.getContextPath()来获取上下文路径,并且需要将其附加到ajax.html
这是一个片段的外观,
TINY.box()。show(' <%= request.getContextPath()%> /ajax.html','show',300,150,true,500);
2.您在“ ajax.html”中缺少引号 。 尝试使用ajax.html且不带引号时,Javascript将引发错误。
经过多次尝试,我得到了一些东西。
它存在此框架的两个版本。
这里是* Tinybox 1 *的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<link rel="stylesheet" href="http://sandbox.scriptiny.com/tinybox/style.css" />
<script type="text/javascript" src="http://sandbox.scriptiny.com/tinybox/tinybox.js"></script>
<script type="text/javascript">
function tiny(show)
{
TINY.box.show("ajax.html",show,300,150,true,5);
}
</script>
</head>
<body>
<label>Name: </label><input type="text" id="name" onclick="tiny(true)"/>
</body>
<html>
如果变量show
的值为true(或1),则似乎tinybox希望通过iframe包含给定的文件。 如果我的IE9,FF21和Chrome浏览器可以打开文件(浏览器抱怨访问验证无效)。 相反,有效的外部URL确实起作用。
这里是* Tinybox 2 *的代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<link rel="stylesheet" href="http://sandbox.scriptiny.com/tinybox2/style.css" />
<script type="text/javascript" src="http://sandbox.scriptiny.com/tinybox2/tinybox.js"></script>
<script type="text/javascript">
function tiny(show)
{
TINY.box.show({iframe:'ajax.html',width:300,height:150})
}
</script>
</head>
<body>
<label>Name: </label><input type="text" id="name" onclick="tiny(true)"/>
</body>
<html>
这个版本确实运行良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.