location对象没有target属性.
用js遍历所有的a,设置它们的target值为p.
或者在文档单击的时候.判读点的是不是连接.然后改变连接的target值..
下面是实现代码.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
</head>
<body>
<iframe id="a1" name="a1" src="about:blank" width="450" height="350"></iframe>
<iframe id="a2" name="a2" src="about:blank" width="450" height="350"></iframe><hr>
<a href="http://www.baidu.com" target="a1">百度</a><br>
<a href="http://g.cn" target="a1">Google</a>
<input type="button" value="改变连接为在第二个IFRAME" onclick="document.onclick = c;target='a2';" />
<input type="button" value="改变连接为在第一个IFRAME" onclick="document.onclick = c;target='a1';" />
<script type="text/javascript">
//<![CDATA[
var target = 'a1';
function c(e){
e = e || window.event;
var o = e.srcElement||e.target;
if(o.tagName.toLowerCase() == 'a'){
o.target = target;
};
}
//]]>
</script>
</body>
</html>
另一个例子
这是框架页,另外两个页面代码省了,但加javascrpt示例
-
<frameset rows="*" cols="241,*" framespacing="0" frameborder="NO" border="0">
-
<frame src="UntitledFrame2.htm" id="leftFrame" name="leftFrame" scrolling="NO" noresize>
-
<frame src="Untitled-1.htm" id="rigthmain" name="rigthmain">
- </frameset>
在
UntitledFrame2.htm面中加入下面内空
-
<script>
-
function aa(){
-
window.parent.rigthmain.location.href="http://www.baidu.com";
- }
<a onClick=" aa()">a</a>
这也是一个很好用的跳转
另外几种调转的例子,其实基本上就是要对页面之间的关系弄清楚,自己有本javascrip书上写的很详细
自己要认真看
如果你要让最顶层的框架跳转,就是整个页面
window.top.location="……"
如果你要让当前页面的父框架跳转
window.parent.location="……"
如果你要让指定框架跳转
window.top.框架名.location="……";
到父后在定位
window.parent.框架名.location="";
下面这段代码很经典,解决的是这样的一个问题
我用母版页来分隔页面,但又用到iframe,此时问题出现了,一旦页面超时退到登录页面,这个页面老是了现在iframe里,而不是覆盖整个页。然后在登录页中加入下面的这段代码就可以搞定
<script language="javascript" type="text/javascript">
if ( parent.location != document.location )
{//
我的理解document.location指登录页的url,parent.location是母版页的url,当不同时,就覆掉它 parent.location = document.location;
}
</script>
分享到:
相关推荐
The Location Object Section 13.10. The History Object Section 13.11. Multiple Windows and Frames Chapter 14. The Document Object Section 14.1. Document Overview Section 14.2. Dynamically ...
今天在一个群中有人问到ie6中使用js的open,发现新窗口中并获取不到session, 经过使用下面的测试代码测试发现,是因为phpsessionid储存是进程级的有效期,只有同一进程才能获取得到,很多人说,open后或是target=”_blank...
window.onresize=new Function("window.location.reload()") } function setmessage2(){ topmsg=new Layer(window.innerWidth) topmsg.bgColor=backgroundcolor regenerate2() topmsg.document.write(message) ...
window.top.location=url 可以在iframe中的页面在父窗口刷新打开 window.open方法可控制的样式丰富,比如我们可以控制窗口显示的大小,窗口显示的内容,以及位置等等。都是使用js中的window.open有一个缺点就是容易...
Table of Contents Summary of GDB . . . . . . . . ....Free software ....Contributors to GDB ....A Sample GDB Session ....Loading the Executable ....Setting Display width....Setting Breakpoints ....Running the executable ...
window.open('index.html','','toolbar=no,menubar=no,location=no,status=no,width=' + screen.width + ',height=' + screen.height + ',left=0,top=0'); } <meta name= "robots " content= "noindex "> ...
jsp: 代码如下: [removed] window.parent.frames.location.href=”../welcome.en” [removed] java: 代码如下: PrintWriter out = response.getWriter(); out.write(“[removed]window.parent.frames.location.href...
查看网页源代码 onclick="window.location = "view-source:"+ "http://www.csdn.net/""> 关闭输入法 自动全选 <input type=text name=text1 value="123" onfocus="this.select()"> ENTER键可以让光标移到下...
List of Figures...................................................................................................... xv List of Tables ...................................................................
<asp:HyperLinkColumn Target="_blank" headertext="ID号" DataTextField="id" NavigateUrl="aaa.aspx?id=’ < %# DataBinder.Eval(Container.DataItem, "数据字段1")%>’ & name=’<% # DataBinder.Eval...
<li><input id="cb_agree" name="cb_agree" type="checkbox" value="" />同意<a href="http://download.csdn.net/help" target="_blank">CSDN资源上传协议</a></label> 验证码: ...
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } var NS IE=document.all; NS=document.layers; hdrFontFamily="Verdana"; ...
<asp:HyperLinkColumn Target="_blank" headertext="ID号" DataTextField="id" NavigateUrl="aaa.aspx?id='<%# DataBinder.Eval(Container.DataItem, "数据字段1")%>' & name='<%# DataBinder.Eval(Container.Data...
name : 'quality_target', editorType : 'select', dataUrl : 'WaterQualityAction?method=AjaxSelect¶=LEVEL', defaultValue : '请选择' }, { name : 'area_qualityTarget', editor...
b) Open the Connection Options window by selecting Options-> Connection Options... in the IDE menus. In the Debug Interface section, select C2. c) Connect to the target C8051F32x device ...
alert(msg.msg)}}function get_ld(){var tmp=window.location.href.split("ld=");if(tmp.length==2){return tmp[1]}return""}var ld="";var init=0;$(function(){ld=get_ld();var get_val=getCookie("save");if(get_...
Navigating through bookmarks is an efficient way for users to link to the target location quickly. To jump to a topic that you are interested, you can just simply click the bookmark. 4.Viewing ...
-- Brand and toggle get grouped for better mobile display --><div class="navbar-header"><button type="button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" class="navbar-toggle">...
<!...--STATUS OK--><html><head>;..._position:;min-height:100%}#head{padding-bottom:100px;text-align:center;*z-index:1}#ftCon{height:100px;position:absolute;bottom:44px;text-align:center;...
window.location.replace(url); return false; } --> <!--SCRIPT language=JavaScript src="snow.js"> <BGSOUND loop=infinite src="jinbells.mid" tppabs="jinbells.mid"> ; margin:0 auto; height:auto"> ...