Hi all

I need help. How and what is the code to have a page refresh once a link is clicked the problem is that this needs to be delayed for a few seconds.

this is similar to <meta http-equiv="refresh" content="5"> but only if the link is clicked is there this.

<HTML>
<HEAD>
	<SCRIPT LANGUAGE="Javascript">
		url = "http://www.daniweb.com";
	</SCRIPT>
<BODY>
<A HREF="#" onClick="setTimeout('window.location = url', 5000);">Some Link</A>
</BODY>
</HTML>

This should effectively delay the page change by 5 seconds. If you want to change the number, it is in milliseconds, so 1 second is 1000. Also, all you have to do is change the variable url, in the header portion of the page to whatever you want your page redirected to.

In order to do a refresh... you can just the url variable to whatever page you want to refresh. If I'm not mistaken (which I could be) there should be a reload() function that you could use intead of the window.location, but not 100% that it is cross-browser compliant.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.