Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript does not work in IE8

The following JavaScript works on IE7 but not on IE8:

onclick=history.back(1) or history.go(-1)

Any suggestions on why this is the case and how to overcome it.


2 Answers

Have you tried:

onclick="history.back()"

with the quotes?


And, responding to your statement that it doesn't work: au contraire, mon ami.

The following two files run fine on my IE8 install, using the files x1.html:

    <html><head></head><body>
        X1
        <hr>
        <a href="x2.html">x2</a>
    </body></html>

and x2.html:

    <html><head></head><body>
        X2
        <hr>
        <button onclick="history.back()">Back!</button>
    </body></html>

When I load x1, I can move to x2 with the link, then the button moves back to x1.

This works in all three compatibility modes, ergo it must be a setting on your browser which is affecting this.

One thing I had to do to get this to work was to go to Tools -> Internet Options -> Advanced -> Security and select Allow active content to run in files on My Computer, so it's almost certainly a security setting in your browser which is causing you grief.

like image 124
paxdiablo Avatar answered Sep 24 '26 06:09

paxdiablo


i used this and works well :

<asp:Button ID="Back_BTN" runat="server" Text="بازگشت" 
onclientclick="javascript:history.back(1);return false;" />
like image 26
mostafa hk Avatar answered Sep 24 '26 05:09

mostafa hk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!