Jump to content

MediaWiki talk:Wikimediaplayer.js

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Mike Dillon (talk | contribs) at 15:49, 23 May 2007 (Fix for link iteration). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Hi there. An issue was identified at Wikipedia:Village Pump (technical)#Prose size script that I believe is caused by a combination of bad behavior in Internet Explorer and this module. In short, the use of a for/in loop with HTMLCollection objects returned from getElementsByTagName("a") has incorrect behavior if there are any named anchors in the page whose name attribute starts with a number (as is the case when section names start with a number). If this is the case, any attempt to use bracket syntax to select the node from the collection will interpret the first part of the name attribute as a number and fail if that numeric index does not exist.

One fix is to use a traditional for loop to fix this. The requested changes is to change the two instances of this code (lines 95 and 125):

for( var key in links )

To be this code:

for( var key = 0; key < links.length; key++ )

This will cause all browsers to use only numeric indexes that are in range and fix problems people are seeing in Internet Explorer. The problems with this script seem to be preventing all user JavaScript from loading on affected pages. Mike Dillon 15:49, 23 May 2007 (UTC)[reply]