I am executing this line from a function -having this code only- that is called on onclick event on a link.
我从一个函数执行这一行代码——只有这段代码——在链接上的onclick事件上调用。
document.getElementById("backButton").href="javascript: history.go(-1);"
But this is not working for IE 7. Can anyone help me on this? Here is the other part of code:
但这并不适用于IE 7。有人能帮我吗?下面是代码的另一部分:
<a id="backButton" title="Go Back To Previous Page" href="./inmaking.html"
onclick="goBack();" onmouseover="status=''; return true;"
style="background-color:#CCCC00;" >here</a> to go back to previous page.
4 个解决方案
#1
1
location.href = document.referrer;
#2
0
Try this instead:
试试这个:
<a id="backButton" title="Go Back To Previous Page" href="javascript:history.go(-1)" onmouseover="status=''; return true;" style="background-color:#CCCC00;" >here</a> to go back to previous page.
#3
0
Your link has a default href
value. To prevent the browser from entering it, you need to add return false;
to end of the onclick
.
您的链接具有默认的href值。为了防止浏览器进入,您需要添加返回false;结束onclick。
onclick="goBack(); return false;"
Needless to say that stepping in browser history using JS like that is a poor practice. Rather store the last requested URL in the session scope or as a hidden input field and finally dynamically populate the link's href
with that using whatever serverside language you're using.
不用说,在浏览器历史上使用JS是一种拙劣的做法。而是将最后请求的URL存储在会话范围或作为隐藏的输入字段中,最后使用您正在使用的任何服务器端语言动态填充链接的href。
#4
0
This one helps for me:
这个对我有帮助:
history.back();
#1
1
location.href = document.referrer;
#2
0
Try this instead:
试试这个:
<a id="backButton" title="Go Back To Previous Page" href="javascript:history.go(-1)" onmouseover="status=''; return true;" style="background-color:#CCCC00;" >here</a> to go back to previous page.
#3
0
Your link has a default href
value. To prevent the browser from entering it, you need to add return false;
to end of the onclick
.
您的链接具有默认的href值。为了防止浏览器进入,您需要添加返回false;结束onclick。
onclick="goBack(); return false;"
Needless to say that stepping in browser history using JS like that is a poor practice. Rather store the last requested URL in the session scope or as a hidden input field and finally dynamically populate the link's href
with that using whatever serverside language you're using.
不用说,在浏览器历史上使用JS是一种拙劣的做法。而是将最后请求的URL存储在会话范围或作为隐藏的输入字段中,最后使用您正在使用的任何服务器端语言动态填充链接的href。
#4
0
This one helps for me:
这个对我有帮助:
history.back();