框架动态JS实现

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>框架测试</title>

<script language="javascript">
function Init()
{
 alert(window.mainFrame.document.getElementById("n"));
 //window.mainFrame.onresize = Handle;
 //window.mainFrame.onresize = new Function("Handle()");
 window.mainFrame.attachEvent("onresize",Handle); //for ie
 //window.mainFrame.addEventListener("resize",method,false); //for ff
 //window.mainFrame.document.onresize = new Function("Handle()");
 //alert(window.mainFrame.document.onresize);
 window.document.attachEvent("onmouseup",IEAlert); //for ie
}

function Handle()
{
//window.onmouseup = new Function("IEAlert()");
HandleUp();
//window.document.attachEvent("onmouseup",IEAlert); //for ie
//After();
//clearTimeout(timeoutID);
 //alert(window.mainFrame.document.getElementById("n"));
 window.mainFrame.document.getElementById("n").value = "Excite";
 //alert(window.mainFrame.document.getElementById("n").value);
}

function IEAlert()
{
var dt = new Date();
alert(dt.getTime());
}
function Empty1()
{
}
function HandleUp()
{

}
function After()
{
 var timeoutID = setTimeout("Empty1()",5000);
clearTimeout(timeoutID);
timeoutID = setTimeout("IEAlert()",5000);
}


</script>
</head>

<frameset οnlοad="Init();" rows="80,*" cols="*" framespacing="1" frameborder="yes" border="1" bordercolor="#FF0000" style="border-color:#006699;" >
  <frame src="topFrame.html" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
  <frameset name="ddd" rows="*" cols="100,*" framespacing="1" frameborder="yes" border="1" bordercolor="#003399">
    <frame src="left.html" name="leftFrame" scrolling="No" id="leftFrame" title="leftFrame" />
    <frame src="right.html" name="mainFrame" id="mainFrame" title="mainFrame"/>
  </frameset>
</frameset>

<noframes><body>
</body>
</noframes></html>
------------------------------------------------------------------------------------------------------------------------

<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
</head>

<body>
<p>right</p>
<p>
  <input type="text" name="n" id="n" value="Your message" onFocus="if(this.value=='Your message')this.value='';">
</p>
<ul id="MenuBar1" class="MenuBarHorizontal">
  <li><a class="MenuBarItemSubmenu" href="#">项目 1</a>
      <ul>
        <li><a href="#">项目 1.1</a></li>
        <li><a href="#">项目 1.2</a></li>
        <li><a href="#">项目 1.3</a></li>
      </ul>
  </li>
  <li><a href="#">项目 2</a></li>
  <li><a class="MenuBarItemSubmenu" href="#">项目 3</a>
      <ul>
        <li><a class="MenuBarItemSubmenu" href="#">项目 3.1</a>
            <ul>
              <li><a href="#">项目 3.1.1</a></li>
              <li><a href="#">项目 3.1.2</a></li>
            </ul>
        </li>
        <li><a href="#">项目 3.2</a></li>
        <li><a href="#">项目 3.3</a></li>
      </ul>
  </li>
  <li><a href="#">项目 4</a></li>
</ul>
<p>&nbsp;</p><!-- Development Note -->
<p>&nbsp;</p>

Example:
<script type="text/javascript">

 

function test()

{

  if (document.layers) getMouseLoc;     //NS

  else if (document.all) getMouseLoc(); //IE

  alert(mouseLocation.x+","+mouseLocation.y);

}
</script>
in the BODY:

<a href="#" οnmοuseοver="test()">test</a>

<script type="text/javascript">

function Point(x,y) {  this.x = x; this.y = y; }

mouseLocation = new Point(-500,-500);

function getMouseLoc(e)

{

  if(!document.all)  //NS

  {

    mouseLocation.x = e.pageX;

    mouseLocation.y = e.pageY;

  }

  else               //IE

  {

    mouseLocation.x = event.x + document.body.scrollLeft;

    mouseLocation.y = event.y + document.body.scrollTop;

  }

  return true;

}

//NS init:

if(document.layers){ document.captureEvents(Event.MOUSEMOVE); document.onMouseMove = getMouseLoc; }

function platformDetect()

{

  if(navigator.appVersion.indexOf("Win") != -1)

  {

    alert("Windows");

  }

  else if(navigator.appVersion.indexOf("Mac") != -1)

  {

    alert("Macintosh");

  }

  else alert("Other");

}

// Example:

// var b = new BrowserInfo();

// alert(b.version);

function BrowserInfo()

{

  this.name = navigator.appName;

  this.codename = navigator.appCodeName;

  this.version = navigator.appVersion.substring(0,4);

  this.platform = navigator.platform;

  this.javaEnabled = navigator.javaEnabled();

  this.screenWidth = screen.width;

  this.screenHeight = screen.height;

}

// * Dependencies *

// this function requires the following snippet:

// JavaScript/readable_MM_functions/findObj

function setColor(objName, fg, bg)

{

  obj = findObj(objName);

  if (obj.style)

  {

    obj.style.color = fg;

    obj.style.backgroundColor = bg;

  }

}

// Example:

// writeCookie("myCookie", "my name", 24);

// Stores the string "my name" in the cookie "myCookie" which expires after 24 hours.

function writeCookie(name, value, hours)

{

  var expire = "";

  if(hours != null)

  {

    expire = new Date((new Date()).getTime() + hours * 3600000);

    expire = "; expires=" + expire.toGMTString();

  }

  document.cookie = name + "=" + escape(value) + expire;

}

// Example:

// alert( readCookie("myCookie") );

function readCookie(name)

{

  var cookieValue = "";

  var search = name + "=";

  if(document.cookie.length > 0)

  {

    offset = document.cookie.indexOf(search);

    if (offset != -1)

    {

      offset += search.length;

      end = document.cookie.indexOf(";", offset);

      if (end == -1) end = document.cookie.length;

      cookieValue = unescape(document.cookie.substring(offset, end))

    }

  }

  return cookieValue;

}

</script>
<p>0000000000A </p>
<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</body>
</html>

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值