返回到上一页的html代码的几种写法

html-css012

返回到上一页的html代码的几种写法,第1张

返回到上一页的html代码的几种写法

1.超链接返回上一页代码:

<a href=”#” onClick=”javascript :history.back(-1)”>返回上一页</a>

<a href=”#” onClick=”javascript :history.go(-1)”>返回上一页</a>

2.用按钮代码:

<input type=”button” name=”Submit” onclick=”javascript:history.back(-1)” value=”返回上一页”>

3.图片代码:

<a href=”javascript :” onClick=”javascript :history.back(-1)”><img src=”图片路径” border=”0″ title=”返回上一页”></a>

[color=#FF0000]几秒钟后[/color]自动返回上一页代码:(加入两个head间,3000表示3秒)

<SCRIPT language=javascript>

function go()

{

window.history.go(-1)

}

setTimeout(“go()”,3000)

</SCRIPT>

“>返回上一页</a>

<script>alert(‘发布失败’)location.href=’index.php’window.history.go(-1)

</script>

扩展资料:

跳转页面的html代码的几种写法

html的实现

<head>

<!-- 以下方式只是刷新不跳转到其他页面 -->

<meta http-equiv="refresh" content="10">

<!-- 以下方式定时转到其他页面 -->

<meta http-equiv="refresh" content="5url=hello.html">

</head>

2. javascript的实现

<script language="javascript" type="text/javascript">

// 以下方式直接跳转

window.location.href='hello.html'

// 以下方式定时跳转

setTimeout("javascript:location.href='hello.html'", 5000)

</script>

3.结合了倒数的javascript实现(IE)

<span id="totalSecond">5</span>

<script language="javascript" type="text/javascript">

var second = totalSecond.innerText

setInterval("redirect()", 1000)

function redirect(){

totalSecond.innerText=--second

if(second<0) location.href='hello.html'

}

</script>

参考资料:百度百科-html代码

HTML页面,ajax是基于id的,所有用id表示。

拿到的数据会显示在这里

<div id="test"></div>

ajax源码:

$(document).ready(function() {

            $.ajax({

                url : "admin/get_online_ganbu.php",//后台请求的数据,用的是PHP

                dataType : "json",//数据格式 

                type : "post",//请求方式

                async : false,//是否异步请求

                success : function(data) {   //如果请求成功,返回数据。

                var html = ""

                for(var i=0i<data.lengthi++){    //遍历data数组

                        var ls = data[i]     

                        html +="<span>测试:"+ls.name+"</span>"

                    }

                    $("#test").html(html) //在html页面id=test的标签里显示html内容

                },

            })

        })

你的ajax中dataType写的是html所以当然返回的是html! ajax中的参数,自己看吧! url: 要求为String类型的参数,(默认为当前页地址)发送请求的地址。 type: 要求为String类型的参数,请求方式(post或get)默认为get。注意其他http请求方法