Javascript代码片断

//1.从当前窗口打开一个新窗口。同时关闭当前窗口。

function OpenWindow()
{

    
var winLeft = window.screen.width/2-320;
    
var winTop = window.screen.height/2-220;

    window.open('www.sina.com','','height
=440,width=640,top='+winTop+',left='+winLeft+',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=yes') ;

    window.opener
=null;        //不加此句,回出现关闭提示 
    window.close();
}

//2。全屏显示窗口
        function fullScreen()
        {
            window.moveTo(
0,0);
            window.resizeTo(window.screen.width,window.screen.height
-30);
            window.focus();
        }

//3. frameset窗口布局
<HTML>
    
<HEAD>
        
<TITLE>International Travel Information Distribution System</TITLE>
        
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        
<meta name="ProgId" content="VisualStudio.HTML">
        
<meta name="Originator" content="Microsoft Visual Studio .NET 7.1">        
    
</HEAD>
    
<frameset id="MainFrame" rows="28,*,1" border="0" frameSpacing="0" frameBorder="0">
        
<frame name="Banner" scrolling="no" noresize target="_selft" src="FrameSet/Banner.aspx">
        
<frameset cols="170,90%,5" frameborder="0" border="0" frameSpacing="0" >
            
<frame name="Nav" scrolling="no" target="Main" src="FrameSet/Navigator.aspx" frameborder="0">
            
<frame name="Main" src="FrameSet/Main.aspx" target="_self" frameborder="0">
            
<frame name="Right" src="FrameSet/Right.aspx" frameborder="0" scrolling="no">
        
</frameset>
        
<frame name="bottom" scrolling="no" noresize target="_selft" src="FrameSet/CopyRight.aspx"
            frameborder
="0">
    
</frameset>
</HTML>
//4.操作Anchor 对象
<html>
<head>

<style type="text/css">
a:active 
{color:green}
</style>


<script type="text/javascript">
function changeLink()
{
document.getElementById('myAnchor').innerHTML
="Visit W3Schools"
document.getElementById('myAnchor').href
="http://www.w3schools.com"
document.getElementById('myAnchor').target
="_blank"
}

function getfocus()
{document.getElementById('myAnchor').focus()}

function losefocus()
{document.getElementById('myAnchor').blur()}

function access()
{
document.getElementById('myAnchor').accessKey
="a"
}


</script>
</head>

<body onload="access()">
<id="myAnchor" href="http://www.microsoft.com">Visit Microsoft</a>
<br /><br />
<input type="button" onclick="changeLink()" value="Change link">
<p>In this example we change the text and the URL of a hyperlink. We also change the target attribute.
The target attribute is by default set to "_self", which means that the link will open in the same window.
By setting the target attribute to "_blank", the link will open in a new window.
</p>
--------------------------------------------------------
<br /><br/>
<input type="button" onclick="getfocus()" value="Get focus">
<input type="button" onclick="losefocus()" value="Lose focus">

<br/>
--------------------------------------------------------
<br /><br/>

<p>(Use Alt + a to give focus to the link.)</p>

</body>

</html>

posted @ 2006-06-09 09:47  烈马狂生  阅读(324)  评论(0编辑  收藏  举报