CuteNews

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> [BUG] IE8 and javascript
FUNimations
post Jun 13 2009, 03:47 PM
Post #1


CuteNews Support Crew Pimp
***

Group: Support
Posts: 16,501
Joined: 28-August 05
From: Belgium
Member No.: 5,662



Name: IE8 and Javascript problem
Author: Damoor
CuteNews Compatibility: ALL CuteNews versions
Description: Well, many will have noticed that in Internet Explorer 8 a whole new set of Javascript rules apply. We don't feel this is a bug on behalf of CuteNews but a fault in the IE8 browser.
Meaning, many Javascript functions don't work anymore. For CN this has also it's consequences.
The only "fix" at the moment is telling IE8 to use the IE7 Javascript rules.
Even when you don't use CuteNews but do use Javascript on your site, it doesn't hurt to add this line of html code.
Instructions:
START EDIT:
Seems the original images.mdu still won't work after that. It does work for the advanced image module made by FI-DD.
END EDIT:
So open images.mdu (even if you're using a hack), compact.skin.php, default.skin.php and simple.skin.php
find all
CODE
<head>

add below or after, and not just between the head tags if you think you're smarter.
CODE
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />


(even facebook uses this so it's bound to be good wink.gif )

EDIT 2: It seems that inserting smilies doesn't work either in IE8 despite the above solution. A solution to this will be posted shortly.
At this point the latest CN version is 1.4.6. As long as this is true, I suggest using UTF-8 CuteNews. It's a spin-off that is more secure and it contains a fix for these Javascript problems.

in images.mdu (not hack) find
CODE
echo"
                      MYRTE=window.opener.document.getElementById(area).contentWindow;
                      window.opener.currentRTE=area; MYRTE.document.execCommand('InsertImage', false, '-my-temp-img-url-');
                      replacement = \"$config_http_script_dir/data/upimages/\" + selectedImage + \"\\\" alt=\\\"\" + alternativeText + \"\\\" border=\\\"\" + imageBorder + \"\\\" align=\\\"\" + imageAlign;
                      MYRTE.document.body.innerHTML = MYRTE.document.body.innerHTML.replace(/-my-temp-img-url-/gi,replacement);

                      ";
and replace with
CODE
MYRTE=window.opener.document.getElementById(area).contentWindow;
                                    window.opener.currentRTE=area;
                      MYRTE.document.body.innerHTML += finalImage;
in addnews and editnews.mdu find
CODE
function preview(){
add above
CODE
function insert_smilie( ttarget, url, name )
    {    
        url = \"<img src='\"+url+\"' title='\"+name+\"' style='border:none;' />\";
        insert_HTML( ttarget, url );
        
    }
    function insert_HTML( ttarget, html )
    {
        MYRTE=document.getElementById(ttarget).contentWindow;
    currentRTE=ttarget;
      MYRTE.document.body.innerHTML += html;
}

in functions.inc.php find
CODE
function insertSmilies($insert_location, $break_location = FALSE, $admincp = FALSE, $wysiwyg = FALSE)
{
    global $config_http_script_dir, $config_smilies;

    $smilies = explode(",", $config_smilies);
        foreach($smilies as $smile)
        {
        $i++; $smile = trim($smile);
              if($admincp){
                    if($wysiwyg){
//                       $advanced_smile = "&lt;img alt=\':$smile:\' src=\'data/emoticons/$smile.gif\' /&gt;";
  //                     $output .= "<a href=# onclick=\"java script:InsertIntoArea('$insert_location','$advanced_smile'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
                       $output .= "<a href=# onclick=\"document.getElementById('$insert_location').contentWindow.document.execCommand('InsertImage', false, '$config_http_script_dir/data/emoticons/$smile.gif'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";

                    }
                    else{ $output .= "<a href=# onclick=\"java script:document.getElementById('$insert_location').value += ' :$smile:'; return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; }
              }else{
                    $output .= "<a href=\"java script:insertext(':$smile:','$insert_location')\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
              }
                if($i%$break_location == 0 and $break_location)
                {
                        $output .= "<br />";
                }else{ $output .= "&nbsp;"; }
    }
        return $output;
}
replace with
CODE
function insertSmilies($insert_location, $break_location = FALSE, $admincp = FALSE, $wysiwyg = FALSE)
{
    global $config_http_script_dir, $config_smilies;

    $smilies = explode(",", $config_smilies);
        foreach($smilies as $smile)
        {
        $i++; $smile = trim($smile);
              if($admincp){
                    if($wysiwyg){
//                       $advanced_smile = "&lt;img alt=\':$smile:\' src=\'data/emoticons/$smile.gif\' /&gt;";
  //                     $output .= "<a href=# onclick=\"java script:InsertIntoArea('$insert_location','$advanced_smile'); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
                       $output .= "<a href=# onclick=\"insert_smilie( '".$insert_location."', '".$config_http_script_dir."/data/emoticons/".$smile.".gif', '".$smile."' ); return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";

                    }
                    else{ $output .= "<a href=# onclick=\"java script:document.getElementById('$insert_location').value += ' :$smile:'; return false;\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>"; }
              }else{
                    $output .= "<a href=\"java script:insertext( ':".$smile.":', ':".$insert_location.":' );\"><img style=\"border: none;\" alt=\"$smile\" src=\"$config_http_script_dir/data/emoticons/$smile.gif\" /></a>";
              };
                if( isset($break_location) && (int)$break_location > 0 && $i%$break_location == 0 )
                {
                        $output .= "<br />";
                }else{ $output .= "&nbsp;"; }
    }
        return $output;
}
and make sure that in the above code the word javascript isn't split into 'java script'.


--------------------

General FAQ
Spam Protection In Cutenews
Comments get deleted
_______________________
<< If you appreciate my help
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 23rd May 2013 - 10:49 PM