How do I add myself an avatar from the public avatar library?
FireFox/Netscape location.hash to empty string --> infinite loop
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What is interesting here?
• Duels
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Register!

QAIX > Javascript web-programming > FireFox/Netscape location.hash to empty string --> infinite loop 19 August 2005 23:05:49

  Top users: 
  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Модератор:

FireFox/Netscape location.hash to empty string --> infinite loop

Stewart 19 August 2005 22:19:11
 
Dear javascripters,

Through a frustrating afternoon of debugging I appear to have
discovered something:

Setting location.hash to an empty string in the global namespace (not
inside a function) Mozilla/FireFox/Net­scape causes the browser to go
into an infinite loop, apparently attempting to reload the page.
ie:
<script type="text/javascri­pt">
<!--
// DON'T DO THIS!!
this.document.locat­ion.hash = '';
//-->
</script>

I'm surely not the only one to have discovered this, but I didn't find
any references to it upon searching the web.

It works fine in IE6, behaving identical with:
this.document.locat­ion.hash = '#';

So do that, or put it in a function, and control when the function gets
called.

Or, as I'm creating this script on the fly in a JSP, don't produce that
code if the reference is empty or null:
<logic:notEmpty name="anchorRef">
this.document.locat­ion.hash = '<bean:write name="anchorRef"/>'­;
</logic:notEmpty>

Wish I'd known 4 hours ago....

Stewart

Add comment
Lee 19 August 2005 22:35:02 permanent link ]
 Stewart said:>
Dear javascripters,>
Through a frustrating afternoon of debugging I appear to have>discovered something:>
Setting location.hash to an empty string in the global namespace (not>inside a function) Mozilla/FireFox/Net­scape causes the browser to go>into an infinite loop, apparently attempting to reload the page.

I don't understand why you would expect it to do anything else.
By setting the hash attribute, you're telling the browser to
reload the page.

Add comment
Stewart 19 August 2005 22:54:45 permanent link ]
 OK, so it's happening in IE6 too, but under different circumstances.
Clicking on a link refering back to this page is sending it into an
infinite loop, but not sure what's wrong with the link at this point.
But commenting out the location.hash = definitely stops it happening.

Add comment
Stewart 19 August 2005 23:05:49 permanent link ]
 I am?

I was wanting it to scroll down to the <a name="anchorRef">In­teresting
bit</a>

I thought location.assign(), location.reload() and location.replace()
were commands to reload the page.

The reference I looked up (www.w3schools.com said: "hash - Sets or
returns the part of the href property that follows the hash sign (#)"

I guess though if window.location = 'http://new_url'; causes a page
reload, then setting the hash might do so also.

Fair enough.

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или законы РФ. Ваш ip-адрес записывается.


QAIX > Javascript web-programming > FireFox/Netscape location.hash to empty string --> infinite loop 19 August 2005 23:05:49

see also:
[SMARTY] R: [SMARTY] How can Smarty be…
[SMARTY] Associative Arrays and…
[SMARTY] Using Javascript to Call…
pass tests:
see also:
How to Convert Video to wma, wav and…
Share an easy way to enjoy DVD and…
Hello!!!!

  Copyright © 2001—2010 QAIX
Идея: Монашёв Михаил.
Авторами текстов, изображений и видео, размещённых на этой странице, являются пользователи сайта.
See Help and FAQ in the community support.qaix.com.
Write in the community about the bugs you have noticedbugs.qaix.com.
Write your offers and comments in the communities suggest.qaix.com.
Information for parents.
Пишите нам на .
If you would like to report an abuse of our service, such as a spam message, please .
Если Вы хотите пожаловаться на содержимое этой страницы, пожалуйста .