• JavaScript-14(操纵属性和window)


    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title>用JS操纵属性和window</title>
    		<style type="text/css">
    			.tiaozhuan{
    				 50px;
    				height: 20px;
    				border-radius: 5px;
    				background-color: orange;
    				color: white;
    				text-align: center;
    				line-height: 20px;
    				margin-top: 12px;
    			}
    		</style>
    	</head>
    	<body>
    		<!--创造一个图片,然后用js实现点击它更换引用路径-->
    		<img src="../img/fengjing.jpg" width="300px"height="170px" onclick="ghlj()"/>
    		<!--点击下面的跳转,通过函数运用window.location.href命令将窗口跳转到指定路径-->
    		<div class="tiaozhuan" onclick="tiaozhuan1()">
    			跳转
    		</div>
    		<!--点击下面的刷新,通过函数运用window.location.reload()命令将窗口刷新-->
    		<div class="tiaozhuan" onclick="shuaxin()">
    			刷新
    		</div>
    		<!--点击下面的向后翻页,通过函数运用window.history.go(1)命令将窗口向后翻,如果将()中改为-1,则向前翻页-->
    		<div class="tiaozhuan" onclick="xh()">
    			向后翻页
    		</div>
    		
    	</body>
    </html>
    
    <script type="text/javascript">
    	//用tupian这个变量接收img标签的集合
    	var tupian = document.getElementsByTagName("img");
    	//运用getAttribute获得这个图片的src属性值;运用setattribute命令把这个图片的“src”属性设为想要改变的图片路径
    	function ghlj(){
    		alert(tupian[0].getAttribute("src"));
    		tupian[0].setAttribute("src","../img/aiji.jpg");
    	}
    	function tiaozhuan1(){
    		window.location.href = "../0328/HTMLjiaocheng.html";
    	}
    	function shuaxin(){
    		window.location.reload();
    	}
    	function xh(){
    		window.history.go(1);
    	}
    </script>
    

      

  • 相关阅读:
    dialog弹层背景overlayer实现的方式
    省略号 对单行 多行的css
    js == 判断
    jquery选择伪元素属性的方法
    psp0级报告
    计算器
    Java学习笔记
    第一个PSP0级
    设计简单登录界面(Java web)
    登录界面及其功能的设计
  • 原文地址:https://www.cnblogs.com/zhangrui0328/p/8858112.html
Copyright © 2020-2023  润新知