现在的位置: 首页 > 综合 > 正文

一些常见的问题与解决代码!(一)

2014年02月23日 ⁄ 综合 ⁄ 共 3115字 ⁄ 字号 评论关闭

在做网页时,想让哪个表格移动,就调用这个JS

<SCRIPT LANGUAGE="JavaScript">
<!--
var currentMoveObj = null;        //当前拖动对象
var relLeft;        //鼠标按下位置相对对象位置
var relTop;
function f_mdown(obj)
{
        currentMoveObj = obj;                //当对象被按下时,记录该对象
        currentMoveObj.style.position = "absolute";
        relLeft = event.x - currentMoveObj.style.pixelLeft;
        relTop = event.y - currentMoveObj.style.pixelTop;
}
window.document.onmouseup = function()
{
        currentMoveObj = null;        //当鼠标释放时同时释放拖动对象
}
function f_move(obj)
{
        if(currentMoveObj != null)
        {
                currentMoveObj.style.pixelLeft=event.x-relLeft;
                currentMoveObj.style.pixelTop=event.y-relTop;
        }
}

//-->
</SCRIPT>
<BODY>
<TABLE width="100" border=1 onselectstart="return false" style="position:absolute;left:50;top:50" onmousedown="f_mdown(this)" onmousemove="f_move(this)">
<TR>
        <TD bgcolor="#CCCCCC" align="center" style="cursor:move">title1</TD>
</TR>
<TR>
        <TD align="center" height="60">content</TD>
</TR>
</TABLE>
<TABLE width="100" border=1 onselectstart="return false" style="position:absolute;left:350;top:250" onmousedown="f_mdown(this)" onmousemove="f_move(this)">
<TR>
        <TD bgcolor="#CCCCCC" align="center" style="cursor:move">title2</TD>
</TR>
<TR>
        <TD align="center" height="60">content</TD>
</TR>
</TABLE>
</BODY>

刷新框架

我有一个框架网页,左右2个网页,现在我在主窗口(右页面)登陆后返回到主窗口页面,我如何让左边页面也能刷新呢?

<body onload="parent.leftFrame.location.reload();">

或者在页面的最后:
<script>
//leftFrame指左边框架的名字
parent.leftFrame.location.reload();
</script>

如何让iframe根据内容适应高度

请问如何让iframe根据内容适应高度
在第一次加载的时候就会自动根据内容适应高度

<iframe src="http://www.baidu.com" onload="this.height = this.document.body.offsetHeight;this.width=this.document.body.offsetWidth;"></iframe>

网页屏保

<script  language="JavaScript">
function  screensave(){
test.value++;
if(test.value==5){
test.style.display='none';
document.all[4].bgColor='black';
}
}
function  screenopen(){
test.value=0;
test.style.display='';
document.all[4].bgColor='';
}
</script>
<body  onkeydown="screenopen()"  onmousemove="screenopen()"  onload="setInterval('screensave()',1000)">
5  秒屏保<input  id="test">

输入字母、数字的正则表达式

<input onkeyup="this.value = this.value.replace(/[^a-zA-Z/d]/g,'')"  onbeforepaste="this.value = this.value.replace(/[^a-zA-Z/d]/g,'')">

alt和title的分行
<a href="#" title="换换换
行行行">test</a>

让标题动态
<script>
<!--
var tx = new Array (
 "◇:::::::网页制作学习园地:::::::◇欢迎您!◇",
 "◆欢迎大家光临网页制作学习园地网站!◆",
 "◆大量供应网页制作教材,资料,源代码,网页制作软件,相关插件光盘!◆",
 "◆最可怕的敌人,就是没有坚强的信念!◆",
 "◆应该让别人的生活因为有了你的生存而更加美好!◆"
);
var txcount=5;
var i=1;
var wo=0;
var ud=1;
function animatetitle()
{
window.document.title=tx[wo].substr(0, i)+"_";
if (ud==0) i--;
if (ud==1) i++;
if (i==-1) {ud=1;i=0;wo++;wo=wo%txcount;}
if (i==tx[wo].length+10) {ud=0;i=tx[wo].length;}
// if (window.document.title.length < 20 ) window.document.title=window.document.title+"-";
// if (window.document.title.length == 20 ) window.document.title=window.document.title+"]";
// if (window.document.title.length == 21 ) setTimeout("window.document.title='Animierte Seitentitel '; ",1000);

parent.window.document.title=tx[wo].substr(0, i)+"_";
setTimeout("animatetitle()",100);
}
animatetitle();
// --></script><script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>

抱歉!评论已关闭.