当前位置: 首页 > 图文教程 > 网络编程 > Javascript > JS实例:登陆失败后跳出框架打开

Javascript
Add a Table to a Word Document
Add Formatted Text to a Word Document
用jscript实现新建word文档
用jscript实现新建和保存一个word文档
Open and Print a Word Document
Use Word to Search for Files
Convert Seconds To Hours
Sample script that deletes a SQL Server database
Sample script that displays all of the users in a given SQL Server DB
firefox中用javascript实现鼠标位置的定位
div+css实现鼠标放上去,背景跟图片都会变化。
Locate a File Using a File Open Dialog Box
Save a File Using a File Save Dialog Box
用jscript实现列出安装的软件列表
List the Stored Procedures in a SQL Server database
Display SQL Server Login Mode
Display SQL Server Version Information
List all the Databases on a SQL Server
用jscript启动sqlserver
Stop SQL Server

Javascript 中的 JS实例:登陆失败后跳出框架打开


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 339 ::
收藏到网摘: n/a

今天遇到个问题,后面在框架中,当判断登录失效后要返回登录页面,但登录页面却在框架内打开,我想让它直接跳出框架打开(这里不是打开新窗口),终于在网上找到了办法,分享给大家:

echo "<script language=\"javascript\">alert('登录已失效或没有登录,请登录!');location.href='login.php';</script>";

原内容是上边这样的,要想让它跳出框架打开登录页,需要使用下面的方法:

echo "<script language=\"javascript\">alert('登录已失效或没有登录,请登录!');window.top.location.href='login.php';</script>";

其实就是在跳转链接前加一个window.top。如果在打开新窗口,可以使用js的window.open("url","打开方式"); 来打开新窗口。