Javascript not working 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 so and how to overcome it.

+3
source share
7 answers

You tried:

onclick="history.back()"

with quotes?


And, in response to your claim that it does not work: au contraire, mon ami.

The following two files work fine on my IE8 installation 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 go to x2with the link, then the button will return to x1.

This works in all three compatibility modes: ergo is the setting of your browser that affects this.

, , , - Tools -> Internet Options -> Advanced -> Security Allow active content to run in files on My Computer, , .

+6

:

<asp:Button ID="Back_BTN" runat="server" Text="بازگشت" 
onclientclick="javascript:history.back(1);return false;" />
+2

. ie7 .

, , IE8. FF3.5

<select size="2">
<option onclick="alert('hey hey')">Hey hey</option>
<option onclick="alert('a ha')">A Ha</option>
</select>

<select onclick="alert('uh oh')" size="2">
<option>Hey hey</option>
<option>A Ha</option>
</select>
+1

, ...

 <a href='javascript:history.back(); ' onclick="history.back(); "><input type="button" value="Back" /></a>

history.back() href, onclick.

+1

history.back(), , history.back(); return false;

0

.

lblmessage.Text += '<br><a href="#" onclick="history.back(1);"> <u>Back</u></a>'

lblmessage.Text += "<br><a href='#' onclick='history.back(1);'> <u>Back</u></a>"
0

This is not an answer, but perhaps it will help someone else to figure out the real answer ... The problem may be related to IE8 compatibility mode. Strange things happen in IE8 based on a DOCTYPE web page. If your DOCTYPE is Transitional, IE8 may not properly handle the onclick event.

0
source

Source: https://habr.com/ru/post/1706507/


All Articles