Hide - Show Layers - Dreamweaver - Javascript error

Hide - Show Layers - Dreamweaver - Javascript error

by rich hahn -
Number of replies: 8

I used Dreamweaver to create a web page that has several layers that are initially hidden.  Then I use a behavior (javascript) to show (visible) a layer when I mouseover a graphic.  This works OK locally and also works OK when I place the html file in the root html directory of my web server

But when I create a Moodle resource and upload the html file, then run it, I get a javascript error (object expected).  If I try to access it directly (http://webserver/vle/file.php/2/test_hide_show.html) I again get a javascript error.  I also tried having the resource point to http://webserver/test_hide_show.html and that works.  So if the file is somewhere under the vle (Moodle) directory I get the javascript error. 

I searched Adobe site and Googled the problem, but the only similar problems I foumd were fixed several browser versions ago.

I don't know PHP, so it wouldn't do me any good to look at the Moodle code.  Any suggestions for solving this problem are greatly appreciated.  I attached the html code but not the graphic.

I am using Moodle 1.5.2. and PHP 1.5.2.  I have tested with both IE 6 and Firefox 1 and get the same results with both.

Thanks

Rich

 

 

Average of ratings: -
In reply to rich hahn

Re: Hide - Show Layers - Dreamweaver - Javascript error

by Jeff Forssell -
I tried your file locally (after changing to a graphic that was lying around that I put in the same folder). I uploaded the file and the graphic into a new folder in moodle (1.5.3+ 2005060231) and used "resource > link to file ..." and browsed to the HTML file and it worked in both FF and IE.

If you want to see:
http://moodle-utv.cfl.se/mod/resource/view.php?id=796
use course key "1984"
In reply to Jeff Forssell

Re: Hide - Show Layers - Dreamweaver - Javascript error

by rich hahn -

Jeff,

Thanks for testing it.  I went to your site, but I'm afraid I don't know Swedish and I couldn't find the resource you created.  What I saw on the page was a forum, a wiki, and a choice (?).  The title was Bokningstest. Was I in the right place?

What was the path in the location field?  When I use http://www.deepelearning.com/test_hide_show.html it works and when I use test_hide_show.html (in the Moodle course directory) I get the Javascript error.  You can access my course at www.deepelearning.com/vle. (login as guest).  The course is under Book Notes and is Designing Effective Instruction. Course Test-Hide-Show loads the file from the html root directory (works) and test2 loads the file from http://deepelearning.com/vle/mod/resource/view.php?id=15 (javascript error).

Rich

 

In reply to rich hahn

Re: Hide - Show Layers - Dreamweaver - Javascript error

by Jeff Forssell -
Sorry!  sad  I noticed that that week was "hidden".  Now it's unhidden.

The link http://moodle-utv.cfl.se/mod/resource/view.php?id=796
should (now) take you directly to that page.

I visited your site and see that it isn't working there. Only suggestion offhand:

Try putting the graphic in the same folder as the HTML page (as I did) in case there is any funny translations of relative links.
In reply to Jeff Forssell

Re: Hide - Show Layers - Dreamweaver - Javascript error

by rich hahn -

Jeff,

I tried image in same directory but still get the javascript error.  I did find something that looks like it is related to problem.  I looked at the source when I ran the file on your site and compared it to the code on my site.  Your code matches my code when I run it locally and when I put the html file in my root html directory (and it runs fine from these locations).  For some reason when I upload the file to Moodle, the information in the MM_showHideLayers() function is changed.  The file stored in the Moodle course directory has the correct function code but somehow it is being modified, I assume either during load or execution.

Code that works -

function MM_showHideLayers()
{ //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
      if ((obj=MM_findObj(args[i]))!=null)
   { v=args[i+2];
       if (obj.style)
     {obj=obj.style;
      v=(v=='show')?'visible'sadv=='hide')?'hidden':v;
    }
      obj.visibility=v;
  }
}

Code that gets error -

function MM_showHideLayers()
{ //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3)
      if ((obj=MM_findObj(args[i]))!=null)
   { v=args[i+2];
       if (obj.style)
     {obj=obj.style;
      v=(v=='show')?'visible'<img alt="sad" width="15" height="15" src="http://deepelearning.com/vle/pix/s/sad.gif" />v=='hide')?'hidden':v;
    }
      obj.visibility=v;
  }
}

I marked the changed code in red.  I have no idea where that code came from.  Does Moodle try to display the sad.gif when it finds a problem?

Rich

In reply to rich hahn

Re: Hide - Show Layers - Dreamweaver - Javascript error

by rich hahn -

Jeff,

Could you give me the version of weblib.php you are using?  It is in the lib directory. Just open it in Wordpad and the first line has the version.

I'm not sure if that is the module that inserts the "sad" code, but I did find an old report of a similar problem that was fixed by a patch of weblib.

Thanks

Rich

In reply to rich hahn

Re: Hide - Show Layers - Dreamweaver - Javascript error

by Jeff Forssell -
// $Id: weblib.php,v 1.469.2.41 2006/04/20 22:30:53 martinlanghoff Exp $

Looked at your second last reply, it seems like the filter which makes smileys into pictures is coming into play and messing things up just like in your example in the post.

I assume there was a : - (  {I had to write it with spaces!}  in what you pasted that became the SAD face. Is there any possibility that you could just put in a space (or two) in that without ruining the syntax?  : - ( or : -(  or :- ( or replacing one or more of the symbols with something that wouldn't be translated.
In reply to Jeff Forssell

Re: Hide - Show Layers - Dreamweaver - Javascript error

by rich hahn -

Jeff,

I upgraded to Moodle 1.6 and my javascript runs fine now. I think the problem with sad smiley was fixed (from bug report) some time in the past, but I couldn't figure out what I needed to do to implement the fix.  .  I first tried replacing the weblib.php with weblib.php v 1.469.2.40  (you are using 1.469.2.41), but that created a new problem and didn't fix my javascript problem. 

My ISP was nice enough to upgrade to Moodle 1.6 at no charge so that seemed the easiest thing to try - and it worked.  Javascript works fine now.

Thanks again.

In reply to rich hahn

Re: Hide - Show Layers - Dreamweaver - Javascript error

by Adrian Keech -
Please note. This problem is actually caused by the Moodle file upload process. Moodle filters all uploaded files and tries to modify the text to improve the user experience. This ends up corrupting javascript in HTML files (still happening in Moodle version 1.7)

You can prevent this happening either by uploading files direct to the course folder using FTP (not tested but I presume it will work) or more simply by turning off filtering for uploaded files (tested and works fine).

To prevent the files being changed go to the moodle configuration settings.

The setting you need to change (in Moodle 1.7) is

Administration >> Configuration >> Filters >> Cache Control

Set "Filter uploaded files" to None