简体   繁体   中英

Go back Javascript not working for Safari

I am trying to implement a go back button using javascript. The code below works fine for ie and firefox. It doesnt work for safari though. Any ideas to fix the problem?

<A href="javascript:history.back()"><IMG border=0 src="imageurl1"></A>`

 I tried history.go(-1) as well. 

Thanks,

You can try making a function with preventDefault like this:

function goBackHistory(){
  history.go(-1);
  event.preventDefault();
}

and then call function from html

<a href="javascript:goBackHistory()"><IMG border=0 src="imageurl1"></a>

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