简体   繁体   中英

How to redirect from html page?

仅仅为了信息,我想知道有没有办法从html页面重定向到另一个,除了window.location.hrefwindow.location ???

There is.

<meta http-equiv="refresh" content="0; url=http://example.com/" />

Remember to place it inside <head>

I dont know why you are neglecting the above mentioned, anyways here you go.

var url = "http://stackoverflow.com";    
$(location).attr('href',url);

You can do it with PHP, but for frontend purposes:

You maybe want to look into window.location.replace since it bypasses the back-button which is often very annoying when it comes to redirects.

You can put this on your head balise

<meta http-equiv="refresh" content="time; URL=your_new_url">

Exemple

<meta http-equiv="refresh" content="5; URL=test.html">

to redirect after 5 seconds at test.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM