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

Javascript
form中限制文本字节数js代码
use jscript with List Proxy Server Information
use jscript List Installed Software
List Installed Software Features
List Information About the Binary Files Used by an Application
List the Codec Files on a Computer
List the UTC Time on a Computer
List Installed Hot Fixes
excel操作之Add Data to a Spreadsheet Cell
Add Formatted Data to a Spreadsheet
Apply an AutoFormat to an Excel Spreadsheet
JavaScript语法着色引擎(demo及打包文件下载)
类之Prototype.js学习
一款JavaScript压缩工具:X2JSCompactor
iis6+javascript Add an Extension File
jscript之Open an Excel Spreadsheet
jscript之Read an Excel Spreadsheet
jscript之List Excel Color Values
去除图像或链接黑眼圈的两种方法总结
Add a Formatted Table to a Word Document

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 356 ::
收藏到网摘: 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","打开方式"); 来打开新窗口。