Moodle

creating multiple links not possible in htmlArea using IE 8

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 1.9.5
  • Fix Version/s: None
  • Component/s: HTML Editor
  • Environment:
    RHEL 5 server - vista/IE 8 client
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_19_STABLE

Description

When using the HTML editor (htmlarea) in IE 8 you can not create two links in the same editor. Attempting to do so yields the following javascript error :

'length' is null or not an object htmlarea.php?id=3425, line 1484 character 9

-------

To reproduce use IE 8 without 'compatibility mode'

Create a new label..
enter in html area:
one<enter>
two<enter>

highlight 'one' and create a link to www.one.com (that will work)
highlight 'two' and try to create a link to www.two.com (you will get the javascript error).

---------

This is probably due to the fact that IE 8 contains some changes... such as this one - detailed here:
"7.) The attributes[] array on elements should (from the RC build onwards) be correct in terms of contents, have a length, etc."
http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/772e4b07-29e1-4909-b77f-f61c503f9579

---------

I hacked together a work around in the patch... I essentially added a check for HTMLArea.is_ie_lt8 and then modified the offending shorthand if to make use of it... see attached patch... not sure if other areas of the code could make use of is_ie_lt8 - haven't found any yet but I'm guessing they are there...

Activity

Hide
Mauno Korpelainen added a comment -

I have been able to add several links with IE8 all the time - maybe this has some realation to http://tracker.moodle.org/browse/MDL-18645

Show
Mauno Korpelainen added a comment - I have been able to add several links with IE8 all the time - maybe this has some realation to http://tracker.moodle.org/browse/MDL-18645
Hide
Neil Streeter added a comment -

It does seem to works with IE in compatibility mode. As I understand it IE will by default consider any site that is in the same domain as your workstation to be on the 'intranet' and will thus use compatibility mode automatically. Not sure if this is why it works for you. Can you check the settings under 'tools > compatibility view settings' to be sure no sites are listed and all three check boxes are unchecked? Particularly the one labeled 'display intranet sites in compatibility mode'? Other than that I restored all of the 'zones' to their default settings using the button under the security settings tab... I've been able to reproduce this on all of the workstations I have tried so I believe this is a real issue.

Thanks,
Neil

Show
Neil Streeter added a comment - It does seem to works with IE in compatibility mode. As I understand it IE will by default consider any site that is in the same domain as your workstation to be on the 'intranet' and will thus use compatibility mode automatically. Not sure if this is why it works for you. Can you check the settings under 'tools > compatibility view settings' to be sure no sites are listed and all three check boxes are unchecked? Particularly the one labeled 'display intranet sites in compatibility mode'? Other than that I restored all of the 'zones' to their default settings using the button under the security settings tab... I've been able to reproduce this on all of the workstations I have tried so I believe this is a real issue. Thanks, Neil
Hide
Mauno Korpelainen added a comment -

You are right, Neil!

I had all check boxes checked and when I unchecked all of them I could reproduce this same error that you get.

Show
Mauno Korpelainen added a comment - You are right, Neil! I had all check boxes checked and when I unchecked all of them I could reproduce this same error that you get.
Hide
Mauno Korpelainen added a comment -

In fact I have never changed those check boxes before - I have used default settings and developer tools of IE8 to test different modes with some IE bugs but never from this compatibility view settings screen.

Show
Mauno Korpelainen added a comment - In fact I have never changed those check boxes before - I have used default settings and developer tools of IE8 to test different modes with some IE bugs but never from this compatibility view settings screen.
Hide
Neil Streeter added a comment -

Whew... I'm glad it's not just me

My little patch is not very 'future proof'... Unfortunately IE 9 will probably be out at some point and at that time is_ie_lt8 will be broken.. probably better to look at the version as an Integer and check based on that. instead of just an indexOf on 'msie 8'... Let me know if I can help further.

ns

Show
Neil Streeter added a comment - Whew... I'm glad it's not just me My little patch is not very 'future proof'... Unfortunately IE 9 will probably be out at some point and at that time is_ie_lt8 will be broken.. probably better to look at the version as an Integer and check based on that. instead of just an indexOf on 'msie 8'... Let me know if I can help further. ns
Hide
Jane Nevin added a comment -

Hi, possibly dumb question, but did you intend your file to be run as a patch file or added to lib/editor/htmlarea/htmlarea.php?
Thanks in advance,
JN

Show
Jane Nevin added a comment - Hi, possibly dumb question, but did you intend your file to be run as a patch file or added to lib/editor/htmlarea/htmlarea.php? Thanks in advance, JN
Hide
Jean-Pierre Pawlak added a comment -

Is it safe to apply this patch?
Why hasn't it been committed?

Show
Jean-Pierre Pawlak added a comment - Is it safe to apply this patch? Why hasn't it been committed?
Hide
Lucian DiPeso added a comment -

I ran into this as well. My fix (similar to the submitted patch) was to just change this line:

if((HTMLArea.is_ie ? attrname.length > 0 : attrname != null)) {

to

if((HTMLArea.is_ie && attrname ? attrname.length > 0 : attrname != null)) {

I tested it on Firefox 3, IE 7, and IE 8, and it seemed to work fine.

Show
Lucian DiPeso added a comment - I ran into this as well. My fix (similar to the submitted patch) was to just change this line: if((HTMLArea.is_ie ? attrname.length > 0 : attrname != null)) { to if((HTMLArea.is_ie && attrname ? attrname.length > 0 : attrname != null)) { I tested it on Firefox 3, IE 7, and IE 8, and it seemed to work fine.
Hide
Nadav Kavalerchik added a comment -

i can confirm that Lucian DiPeso's fix worked for me too
(moodle version 1.9.4)

before i used the patch, it was broken when we were using IE8
and it was working fine on FF3 and IE7 (IE8's compatibility mode)

thanks

Show
Nadav Kavalerchik added a comment - i can confirm that Lucian DiPeso's fix worked for me too (moodle version 1.9.4) before i used the patch, it was broken when we were using IE8 and it was working fine on FF3 and IE7 (IE8's compatibility mode) thanks
Hide
Mauno Korpelainen added a comment -

I can confirm it as well and in http://tracker.moodle.org/browse/MDL-19396 Greg Milsted had a little shorter version of patch that works as well as:

if((HTMLArea.is_ie ? attrname : attrname != null)) {

I have used this Greg's version since the end of September - "somebody" (who has access to htmlarea.php) should just change that one line in htmlarea.php

Show
Mauno Korpelainen added a comment - I can confirm it as well and in http://tracker.moodle.org/browse/MDL-19396 Greg Milsted had a little shorter version of patch that works as well as: if((HTMLArea.is_ie ? attrname : attrname != null)) { I have used this Greg's version since the end of September - "somebody" (who has access to htmlarea.php) should just change that one line in htmlarea.php
Hide
Andreas Grupp added a comment -

Hmmm ... a bug with working patch from August last year and still not fixed . After a complaint from a user I had to search a while to find this and the attached solution from Neil. Bug is assigned to nobody!

I can confirm that the bug is still in Moodle. Used current version Moodle 1.9.8+ (Build: 20100414) and changed the two lines as described with the patch. Works perfect and looks like a clean solution! Perhaps the owner of the bug can add all Moodle versions until 1.9.8+ (Build: 20100414) as affected.

Show
Andreas Grupp added a comment - Hmmm ... a bug with working patch from August last year and still not fixed . After a complaint from a user I had to search a while to find this and the attached solution from Neil. Bug is assigned to nobody! I can confirm that the bug is still in Moodle. Used current version Moodle 1.9.8+ (Build: 20100414) and changed the two lines as described with the patch. Works perfect and looks like a clean solution! Perhaps the owner of the bug can add all Moodle versions until 1.9.8+ (Build: 20100414) as affected.
Hide
miki Alliel added a comment -

I want to confirm that in Moodle 1.9.8 this problem still occurs.
But I used the "if((HTMLArea.is_ie && attrname ? attrname.length > 0 : attrname != null)) {" fix of Lucian DiPeso works for me in Moodle 1.9.8.

Show
miki Alliel added a comment - I want to confirm that in Moodle 1.9.8 this problem still occurs. But I used the "if((HTMLArea.is_ie && attrname ? attrname.length > 0 : attrname != null)) {" fix of Lucian DiPeso works for me in Moodle 1.9.8.
Hide
Neil Streeter added a comment -

The more correct fix is certianly that provided by Lucian...

..... just change this line:

if((HTMLArea.is_ie ? attrname.length > 0 : attrname != null)) {

to

if((HTMLArea.is_ie && attrname ? attrname.length > 0 : attrname != null)) {

ns

Show
Neil Streeter added a comment - The more correct fix is certianly that provided by Lucian... ..... just change this line: if((HTMLArea.is_ie ? attrname.length > 0 : attrname != null)) { to if((HTMLArea.is_ie && attrname ? attrname.length > 0 : attrname != null)) { ns
Hide
Scott A added a comment -

So is anybody going to close this with the working fix?

I've got staff here at our school that are wanting to edit a moodle site and they can't as our whole school runs on IE8. I tell them to hit compatibility view in IE to be able to edit the site and add links properly, but as soon as they hit compatibility view, the menu bar that the site uses disappears.

Great work so far on finding that solution, I'll see if I can get our website guys at the board office of our school district to make the change to the code as I cannot.

Show
Scott A added a comment - So is anybody going to close this with the working fix? I've got staff here at our school that are wanting to edit a moodle site and they can't as our whole school runs on IE8. I tell them to hit compatibility view in IE to be able to edit the site and add links properly, but as soon as they hit compatibility view, the menu bar that the site uses disappears. Great work so far on finding that solution, I'll see if I can get our website guys at the board office of our school district to make the change to the code as I cannot.
Hide
Ian Wild added a comment -

Any response to Scott A's comment?

We're also using IE 8.0 and are going to be stuck with this issue (we are runnin 1.9.9). We are happy to mod the code but what is the progress on this?

Show
Ian Wild added a comment - Any response to Scott A's comment? We're also using IE 8.0 and are going to be stuck with this issue (we are runnin 1.9.9). We are happy to mod the code but what is the progress on this?

Dates

  • Created:
    Updated: