
UICollectionViewCell cell = (UICollectionViewCell )[collectionView
cellForItemAtIndexPath:indexPath];一句话就能获取到点击cell的frame,十分好用,同样适用于tableView。
二、Window对象的属性和方法
Window对象共有七个属性:
● defauleStatus:指定窗口状态栏中的信息。
● status:指定当前窗口状态栏中的信息。
● frames:是一个数组,其中内容是窗口中所有的框架。
● parent:指当前窗口的父窗口。
● self:指当前窗口。
● top:代表当前所有窗口的最顶层窗口。
● window:代表当前窗口。
Window对象有五个方法:
● alert:显示带有一个“确定”按钮的对话框。
● confirm:显示带有“确定”与“取消”两个按钮的对话框。
● prompt:显示带有输入区的对话框。
● open:打开一个新窗口。
● close:关闭用户打开的窗口。
三、status属性例子,在窗口状态栏显示和清除文字
单击"写入文字"按钮,在状态栏显示'这是状态栏'。按"清除文字"按钮,清除状态栏的文字。
<html>
<head>
<script language="JavaScript">
function statbar(txt) {
windowstatus = txt; }
</script>
</head>
<body>
<form>
<input type="button" name="look" value="写入文字" onclick="statbar('这是状态栏');">
<input type="button" name="erase" value="清除文字" onclick="statbar('');">
</form>
</body>
</html>
四、alert方法例子:显示“大家来学习JavaScript脚本语言。”的对话框。
<html>
<body>
<script language="JavaScript">
alert("大家来学习JavaScript脚本语言。")
</script>
</body>
</html>
五、 Confirm方法例子:让用户选择是否进入下一页。
用confirm显示选择对话框,按“确定”进入nexthtm,按“取消”不进入。
<html>
<body>
<script language="JavaScript">
if(confirm("你想进入下一页吗?"))
location="nexthtm"
</script>
</body>
</html>
六、Prompt方法例子:让用户输入姓名,并将它显示出来。
用prompt显示输入对话框,让用户输入姓名,再用alert对话框显示出来。
<html>
<body>
<script language="JavaScript">
var name
name=prompt("请输入姓名","张国强")
alert("你好,"+name)
</script>
</body>
</html>
七、Window对象方法例子
当打开网页时,立即打开另一窗口,显示testhtm。
<html>
<body onload="javascript:windowopen('testhtm')">
</body>
</html>
八、History对象的属性和方法
History对象只有一个length属性,它表示历史对象中的链接的数目。
History对象有以下方法:
● back:在浏览器中显示上一页。
● forward:在浏览器中显示上下页。
● go(int):在浏览器中载入从当前算起的第int个页面。
九、History例子:具有“上一页”、“下一页”按钮的页面。
<html>
<body>
<form>
<input type="button" value="上一页" onClick="historyback()">
<input type="button" value="下一页" onClick="historyforward()">
</body>
</html>
javascript中的locationhref有很多种用法,主要如下。
selflocationhref=”/url” 当前页面打开URL页面
locationhref=”/url” 当前页面打开URL页面
windowslocationhref=”/url” 当前页面打开URL页面,前面三个用法相同。
thislocationhref=”/url” 当前页面打开URL页面
parentlocationhref=”/url” 在父页面打开新页面
toplocationhref=”/url” 在顶层页面打开新页面
如果页面中自定义了frame,那么可将parent self top换为自定义frame的名称,效果是在frame窗口打开url地址
此外,windowlocationhref=windowlocationhref;和windowlocationReload()和都是刷新当前页面。区别在于是否有提交数据。当有提交数据时,windowlocationReload()会提示是否提交,windowlocationhref=windowlocationhref;则是向指定的url提交数据
在写ASPNet程序的时候,我们经常遇到跳转页面的问题,我们经常使用ResponseRedirect 做ASPNET框架页跳转,如果客户要在跳转的时候使用提示,这个就不灵光了,如:
ResponseWrite("< script>alert('恭喜您,注册成功!');< /script>");
ResponseRedirect("mainhtml");
这时候我们的提示内容没有出来就跳转了,和ResponseRedirect("mainhtml");没有任何区别。
这时我们采用下面代码试验一下:
ASPNET框架页跳转的另一实现
ResponseWrite("< script language=javascript>alert('恭喜您,注册成功!')< /script>");
ResponseWrite("< script language=javascript>windowlocationhref='mainhtml'< /script>");
这个即实现了我们的要求,在提示后,跳转页面。
最重要的是windowlocationhref 语句可以实现一个框架的页面在执行服务器端代码后刷新另一个框架的页面(ResponseRedirect无法达到,至少我没有发现):
如:indexhtm页面中有二个框架,分别为 frameLeft和frameRight,在frameRight页面中执行服务器端代码后刷新frameLeft中的页面。
先前最常见的是注册之后,自动刷新登陆框,让登陆框换成已登陆页面,只要在注册成功的代码之后加上一段,即可以实现刷新另个框架的页面。代码如下:
ResponseWrite("< script language=javascript>alert('恭喜您,注册成功!')< /script>");
ResponseWrite("< script language=javascript>windowparentframeLeftlocationhref='mainhtml'< /script>");
这样就搞定了ASPNET框架页跳转中断的问题。
=====================================================================================
"windowlocationhref"、"locationhref"是本页面跳转
"parentlocationhref"是上一层页面跳转
"toplocationhref"是最外层的页面跳转
举例说明:
如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写
"windowlocationhref"、"locationhref":D页面跳转
"parentlocationhref":C页面跳转
"toplocationhref":A页面跳转
如果D页面中有form的话,
: form提交后D页面跳转
: form提交后d出新页面
: form提交后C页面跳转
: form提交后A页面跳转
关于页面刷新,D 页面中这样写:
"parentlocationreload();": C页面刷新 (当然,也可以使用子窗口的 opener 对象来获得父窗口的对象:windowopenerdocumentlocationreload(); )
"toplocationreload();": A页面刷新
以上就是关于如何计算uicollectionviewcell相对于window的frame全部的内容,包括:如何计算uicollectionviewcell相对于window的frame、JavaScript中window对象常用的属性、方法、网页的windows和frame有什么区别等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)