Михаил Аксёнов (xeningem) wrote in lj_dev,
Михаил Аксёнов
xeningem
lj_dev

  • Mood:
  • Music:

Problem with comments in Opera. Solution.

Users who use Opera detect that the standart style of comments isn't working in their browser correctly.
As far as I know, that has happened not long ago, however I don't have a page with an old code and that's why I've tried to modify the current code, in order to return functionality for my browser.
The problem is that Opera doesn't work correctly with the forms that are created by an innerHTML (it simply deletes them), but it can be solved with an addition of a simple code
I just added in a script, that is placed in end of every page with post, new form named "qrform" (Yes, I know, that this code has a form with this name, but it is placed in an innerHTML part of variable "de").
So, I've taken away the form named qrform from de.innerHTML, and initiated it separately with the rest of the code, which is placed in this form.
// This code must placed after  if (bodye[0])... but before next }
var bodye = document.getElementsByTagName("body");
if (bodye[0]) bodye[0].insertBefore(de, bodye[0].firstChild);
de.style.display = 'none';

[code]
if (!document.getElementById("qrform")&&document.getElementById("qrformdiv"))
{
var qe = document.getElementById("qrformdiv");
var fe = document.createElement("form");      
if (fe&&qe)
  {
  fe.id = "qrform";
  fe.name="qrform";
  fe.method="POST";
  fe.action="http://www.livejournal.com/talkpost_do.bml";         
  fe.innerHTML =qe.innerHTML;
  qe.innerHTML = "";
  qe.appendChild(fe);
  }
}
[/code]
}</script>
// Also Opera users may add follow code in new UserJavaScript file, detail of using and installing - http://userjs.org
[code]
window.addEventListener('load',function(e)
{
if (!document.getElementById("qrform")&&document.getElementById("qrformdiv"))
{
var qe = document.getElementById("qrformdiv");
var fe = document.createElement("form");      
  if (fe)
  {
  fe.id = "qrform";
  fe.name="qrform";
  fe.method="POST";
  fe.action="http://www.livejournal.com/talkpost_do.bml";         
  fe.innerHTML =qe.innerHTML;
  qe.innerHTML = "";
  qe.appendChild(fe);
  }
}
},false);
[/code]
p.s. I'm create USJ file with this code - and I have working comments in Opera. :)
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 6 comments