点击按钮后刷新页面,然后调用一个函数 [英] Refresh page on button click and after that call an function

查看:169
本文介绍了点击按钮后刷新页面,然后调用一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试刷新按钮点击的网页,并在页面刷新后调用一个函数。
但是反过来没有发生,即首先调用函数,然后刷新页面。

I am trying to refresh an web page on button click and after page refresh call an function. But its reverse is not happening i.e. first call the function and after that refresh the page.

这是我试过的:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script>
    function restartall(){
        $('#text').append('hello');
    }
</script>
<a href="javascript:document.location.reload();">
<button onclick="restartall()">Referash Map</button></a>
<div id="text"></div>

请解决此查询。

推荐答案

<a href="javascript:abc();"><script>function restartall() {
    $('#text').append('hello');
}

function abc() {
    document.location.reload();
    restartall();

}</script>

这篇关于点击按钮后刷新页面,然后调用一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆