admin 管理员组文章数量: 1086019
i have a tiny JS problem:
If a user visits a special site i would like to automatically add an anchor to that url for design reasons -> result
.
After 10 seconds i would like to change the anchor to
Is this possible in some way? Maybe with window.location?
big thx for any help!
i have a tiny JS problem:
If a user visits a special site http://www.test.de
i would like to automatically add an anchor to that url for design reasons -> result http://www.test.de/#wele
.
After 10 seconds i would like to change the anchor to http://www.test.de/#thankyou
Is this possible in some way? Maybe with window.location?
big thx for any help!
Share Improve this question asked Nov 9, 2010 at 16:33 LupoLupo 3,1045 gold badges27 silver badges30 bronze badges3 Answers
Reset to default 8You could use window.location.hash
here
window.onload = function(){
window.location.hash = 'wele';
setTimeout( function(){
window.location.hash = 'thankyou';
}, 10*1000);
};
window.onload = function ()
{
window.location.hash = '#wele';
setTimeout(function ()
{
window.location.hash = '#thankyou';
}, 10*1000);
}
MDC window.onload()
docs
MDC window.location.hash
docs
The first part of your question - remapping www.test.de
to www.test.de/#wele
can be done using URL rewriting. See mod_rewrite for Apache installations or urlrewrite for IIS
The second could easily be done using a JavaScript timer and window.location as you have suggested.
<script type="text/javascript">
setTimeout("window.location.href='http://www.test.de/#thankyou'", 10000); // 10 secs
</script>
Although I would question this approach from a user experience perspective. If you are actually referring to specific anchors within the document body, then the user might be dismayed to find his screen jumping to a new part of the page after 10 seconds. If there are no corresponding anchors, then it's just odd (though not necessarily bad).
本文标签: http redirectJavascriptadd anchor for design reasonsStack Overflow
版权声明:本文标题:http redirect - Javascript - add anchor for design reasons - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1743995186a2515445.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论