Moodle

Javascript error with popup blocker enabled

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.1
  • Fix Version/s: 1.9.5
  • Component/s: General
  • Labels:
    None
  • Environment:
    browser with a popup blocker
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

The openpopup function in /moodle/lib/javascript.php generate an error at next reference to windowobj object after window.open try.

If the popup blocker blocks the window.open no object esists so next call fails.

We can simply add
if (windowobj) {
after windowobj = window.open(fullurl,name,options);
and close the brachet before return false;

to solve it.

Cheers,
Roberto

Activity

Hide
Urs Hunkler added a comment -

Another possible Patch

Index: javascript.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/javascript.php,v
retrieving revision 1.36.2.3
diff -u -r1.36.2.3 javascript.php
— javascript.php 18 Jul 2008 07:14:12 -0000 1.36.2.3
+++ javascript.php 30 Mar 2009 16:28:12 -0000
@@ -34,13 +34,13 @@
<script type="text/javascript">
//<![CDATA[
function openpopup(url,name,options,fullscreen) {

  • fullurl = "<?php echo $CFG->httpswwwroot ?>" + url;
  • windowobj = window.open(fullurl,name,options);
  • if (fullscreen) {
    + var fullurl = "<?php echo $CFG->httpswwwroot ?>" + url;
    + var windowobj = window.open(fullurl,name,options);
    + if (fullscreen && windowobj) { windowobj.moveTo(0,0); windowobj.resizeTo(screen.availWidth,screen.availHeight); }
  • windowobj.focus();
    + if(windowobj) windowobj.focus();
    return false;
    }
Show
Urs Hunkler added a comment - Another possible Patch Index: javascript.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/javascript.php,v retrieving revision 1.36.2.3 diff -u -r1.36.2.3 javascript.php — javascript.php 18 Jul 2008 07:14:12 -0000 1.36.2.3 +++ javascript.php 30 Mar 2009 16:28:12 -0000 @@ -34,13 +34,13 @@ <script type="text/javascript"> //<![CDATA[ function openpopup(url,name,options,fullscreen) {
  • fullurl = "<?php echo $CFG->httpswwwroot ?>" + url;
  • windowobj = window.open(fullurl,name,options);
  • if (fullscreen) { + var fullurl = "<?php echo $CFG->httpswwwroot ?>" + url; + var windowobj = window.open(fullurl,name,options); + if (fullscreen && windowobj) { windowobj.moveTo(0,0); windowobj.resizeTo(screen.availWidth,screen.availHeight); }
  • windowobj.focus(); + if(windowobj) windowobj.focus(); return false; }
Hide
Tim Hunt added a comment -

Fixed.

Show
Tim Hunt added a comment - Fixed.
Hide
Dongsheng Cai added a comment -

Thanks, closing

Show
Dongsheng Cai added a comment - Thanks, closing

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: